Note that there are some explanatory texts on larger screens.

plurals
  1. POI am not getting the right result, not sure what I am missing (improper logic, missing steps?)
    primarykey
    data
    text
    <p>I am trying to get this problem to work right, what it does it ask for some scores to be entered and then it is supposed to show the name of the person with the highest score. I am getting the last score entered as the highest score, the problem with that is the last score entered is not going to necessarily be the highest one entered. Any ideas on how I can fix this would be appreciated. This is homework and just so nobody says "use a list or array" we have not covered that in class and thus are not supposed to use it for this problem.</p> <pre><code> public static void main(String[] args) { // variables Scanner input = new Scanner(System.in); int count = 0; int numStudents; double grade = 0, highestGrade = 0; String name = "", highName = ""; String numGrades = JOptionPane.showInputDialog ("How many student grades are you entering: "); numStudents = Integer.parseInt(numGrades); //for(int count = 0; count &lt; numStudents; count++) while(count &lt; numStudents) { // prompt for the user to enter grades String inputName = JOptionPane.showInputDialog("Enter a student name: "); name = inputName; //name = input.next(inputName); String inputGrade = JOptionPane.showInputDialog("What is that students grade: "); grade = Double.parseDouble(inputGrade); //grade = input.nextDouble(); count++; //if(grade &lt; highestGrade) if(highestGrade &gt; grade) { name = highName; grade = highestGrade; } else { continue; } } JOptionPane.showMessageDialog (null, "The student with the highest score is " + name + " with a grade of " + grade); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload