125k views
4 votes
Create a NetBeans project named Project3. In Project3, create a main class with the name FindTwoHighestScores. In the FindTwoHighestScores main() method body, write a program that prompts the user to enter the number of students and each student's name and score, and finally displays the name of the student with the highest score and the name of the student with the second-highest score.

From the Project Navigator you can run the new program by right clicking on the file name and selecting 'Run File' or if the file is active in the NetBeans code editor window, press 'Shift - F6'. Here is a sample run in NetBeans. Your program's user prompts and final output must look exactly like this. Please note that every user input is followed by the Enter key:
Enter the number of students: 6
Enter a student name: Guillermo Horne
Enter Guillermo Horne's score: 29
Enter a student name: Jan Bridges
Enter Jan Bridges's score: 62
Enter a student name: Blake Williams
Enter Blake Williams's score: 60
Enter a student name: Makaila Yates
Enter Makaila Yates's score: 96
Enter a student name: Eden Hinton
Enter Eden Hinton's score: 99
Enter a student name: Gerald Arroyo
Enter Gerald Arroyo's score: 59
Top two scores:
Eden Hinton's score is 99.0
Makaila Yates's score is 96.0

1 Answer

7 votes

Final answer:

Creating the FindTwoHighestScores class in a NetBeans Project3 involves setting up a user input loop to collect names and scores, tracking the highest and second-highest scores, and then outputting these scores and names after all data is entered.

Step-by-step explanation:

To create a NetBeans project that identifies the top two scoring students among a group, you need to follow a series of steps in Java programming. Below you will find instructions and a sample code snippet for the FindTwoHighestScores class:

First, in NetBeans, create a new project named Project3. In this project, create a new Java Class named FindTwoHighestScores. Within the main method of this class, use a Scanner object to receive user input. Then, set up a loop to collect each student name and score. Use two separate variables to keep track of the highest and second-highest scores along with the corresponding student names. After all data is entered, print out the top two scores and the names of their respective students.

Here is a pseudocode of the steps needed:


  1. Import the Scanner class.

  2. Declare variables for storing the highest and second-highest scores and names.

  3. Prompt the user to enter the number of students.

  4. Set up a loop based on the number of students entered. Within this loop:

  5. Get each student's name and score.

  6. Check if the score is higher than the current highest or second-highest score and update your variables accordingly.

After exiting the loop, output the names and scores of the top two students like so:

Top two scores:
StudentName1's score is Score1.
StudentName2's score is Score2.

Make sure the final output of your program matches the provided sample run exactly for full credit. Ensure that you handle the logic to correctly identify the highest and second-highest scoring students.

User Walk
by
8.5k points