Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Scott Dunning Newsgroups: comp.lang.java.programmer Subject: Re: Class assignment help Date: Sun, 20 Jul 2014 21:57:40 -0700 Organization: A noiseless patient Spider Lines: 71 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 21 Jul 2014 04:55:17 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="11828741c91d0da908948c6ecdf164c7"; logging-data="3427"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181lSmcRcKAiiBzhJBVx1g/BWqRqOUKZrk=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: Cancel-Lock: sha1:OPYK1DfgFE8fEp85+PPE3RhIuGk= Xref: csiph.com comp.lang.java.programmer:29144 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); > > } > }