10 replies on 1 page. Most recent reply: Jun 25, 2019 5:35 AM by nova jones
int grade1 = 88 - 100, grade2 = 80 - 87, grade3 = 67 - 79, grade4 = 60 - 67, grade5 = 0 - 60; // not sure if this part is correct
String inputString = JOptionPane.showInputDialog(null, "Enter Grade: ", "Benjamin Shively", JOptionPane.PLAIN_MESSAGE); //You need code between these two String message = ("Numeric Grade is: " + inputString + "\nYour Letter Grade Is: " + something + "\n\n" + "To Continue Press Enter. \n" + "To exit Press 'x': ");
String inputString; //other code inputString = JOptionPane.showInputDialog(null, "Enter Grade: ", "Benjamin Shively", JOptionPane.PLAIN_MESSAGE);
//wrong String inputString = JOptionPane.showInputDialog(null, "Enter Grade: ", "Benjamin Shively", JOptionPane.PLAIN_MESSAGE); //right inputString = JOptionPane.showInputDialog(null, "Enter Grade: ", "Benjamin Shively", JOptionPane.PLAIN_MESSAGE);
if(A condition) letterGrade = "A"; else if(B condition) //other code else letterGrade = "F";
//You have this in two places, you don't need the one outside the loop. inputString = JOptionPane.showInputDialog(null, "Enter Grade: ", "Benjamin Shively", JOptionPane.PLAIN_MESSAGE); //Two problems here. First of all, inputString is a String, so it can't store numbers. //What does store numbers is grade! while (!(inputString > 0 || inputString < 100)) { //not sure if the while is right inputString = JOptionPane.showInputDialog(null, "Enter Grade: ","Benjamin Shively", JOptionPane.PLAIN_MESSAGE); //You skipped step 3 here. You must convert the data from a String to an int so it can //be stored in grade. The Integer class has a method to help you do that. if (grades < 0 || grades > 100) //I think you want this to display message2, but you have to create message2 FIRST. //But you need to use a block with your if for that to happen. JOptionPane.showInputDialog(null, message, "Benjamin Shively", JOptionPane.PLAIN_MESSAGE); String message2 = ("Invalid Entry:" + inputString + "\n\n" + "Enter Valid Grade Again:");
inputString.equalsIgnoreCase("x")
if(inputString == null) inputString = "";
while ((inputString == null) || //rest of your code)
while(! "x".equalsIgnoreCase(inputString))