Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #29144

Re: Class assignment help

From Scott Dunning <scottwd01@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Class assignment help
Date 2014-07-20 21:57 -0700
Organization A noiseless patient Spider
Message-ID <lqi6fl$3b3$1@dont-email.me> (permalink)
References <lqi67a$1nt$2@dont-email.me>

Show all headers | View raw


On 7/20/14, 9:53 PM, Scott Dunning wrote:

I sent that message prematurely.  I'm in a class in college and we're 
doing Java.  This is only my 4th class so I'm super new (be nice).  I'm 
getting an error that I don't understand...

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

	at StudentScore.StudentScore.main(StudentScore.java:14)







> /*Write a java program that prompts the user to enter the number of
> students and then each student’s name and score,
>   * and finally displays the student with highest score and the student
> with the second- highest score.
>   * You are NOT allowed to use ‘Arrays’ for this problem (as we have not
> covered arrays yet).
>   *
>   * HINT: You do not need to remember all the inputs. You only need to
> maintain variables for max and second max
>   *  scores and corresponding names. Whenever you read a new input, you
> need to compare it to the so far established
>   *  max & second max scores and change things accordingly. */
>
>
> import java.util.Scanner;
>
> public class StudentScore {
>
>      public static void main(String[] args) {
>
>          String studentName, highName, secondHighName;
>          int score, highScore=0, secondHighScore=0;
>          int count;
>          int classSize;
>
>          Scanner scan = new Scanner(System.in);
>
>          System.out.print("How many students' grades do you want to
> enter? ");
>          classSize = scan.nextInt();
>
>          for (int i = 0; i < classSize; i++)  {
>              System.out.print("Please enter the students name? ");
>              studentName = scan.nextLine();
>
>              System.out.print("Please enter the students score? ");
>              score = scan.nextInt();
>
>              if (score >= secondHighScore) {
>                  secondHighScore = highScore;
>                  secondHighName = highName;
>                  highScore = score;
>                  highName = studentName;
>
>              }
>          }
>
>          System.out.print("Student with the highest score: " + highName
> + " " + highScore);
>          System.out.print("Student with the second highest score: " +
> secondHighName + " " + secondHighScore);
>
>      }
> }

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Class assignment help Scott Dunning <scottwd01@gmail.com> - 2014-07-20 21:53 -0700
  Re: Class assignment help Scott Dunning <scottwd01@gmail.com> - 2014-07-20 21:57 -0700
    Re: Class assignment help Roedy Green <see_website@mindprod.com.invalid> - 2014-07-20 22:55 -0700
      Re: Class assignment help Scott Dunning <scottwd01@gmail.com> - 2014-07-20 23:59 -0700
        Re: Class assignment help Tim Slattery <tim@risingdove.com> - 2014-07-21 10:50 -0400
          Re: Class assignment help Roedy Green <see_website@mindprod.com.invalid> - 2014-07-21 12:35 -0700
            Re: Class assignment help Scott Dunning <scottwd01@gmail.com> - 2014-07-21 14:22 -0700
            Re: Class assignment help Scott Dunning <scottwd01@gmail.com> - 2014-07-21 14:29 -0700
              Re: Class assignment help Jeff Higgins <jeff@invalid.invalid> - 2014-07-21 17:30 -0400
                Re: Class assignment help Scott Dunning <scottwd01@gmail.com> - 2014-07-21 15:26 -0700
                Re: Class assignment help Scott Dunning <scottwd01@gmail.com> - 2014-07-21 15:34 -0700
                Re: Class assignment help Jeff Higgins <jeff@invalid.invalid> - 2014-07-21 18:35 -0400
                Re: Class assignment help Jeff Higgins <jeff@invalid.invalid> - 2014-07-21 20:55 -0400
                Re: Class assignment help markspace <markspace@nospam.nospam> - 2014-07-22 10:42 -0700
                Re: Class assignment help Scott Dunning <scottwd01@gmail.com> - 2014-07-23 17:55 -0700
                Re: Class assignment help cdalten@gmail.com - 2014-07-30 20:58 -0700
                Re: Class assignment help cdalten@gmail.com - 2014-07-30 21:00 -0700

csiph-web