Get answer

Hide Assignment InformationInstructionsProgramming Project 2: Chapters 3 and 4 You will use what you have learned from Chapters 1- 2- 3- and 4 in Big Javascript Late Objects to complete the following

Hide Assignment InformationInstructionsProgramming Project 2: Chapters 3 and 4

You will use what you have learned from Chapters 1, 2, 3, and 4 in Big Javascript Late Objects to complete the following program.  Use what you have learned about the Scanner class, Constants, variables, printf, Strings, Decisions, and Loops to complete the project.

Remember to watch the Lecture Videos and additional videos in iCollege for examples on these topics and how to comment your program correctly.  **Please do not use any advanced material that is not in Chapters 1 – 4.

We will be completing our Programming Projects using Code Check.  Nothing is required by you to use this program.  For each project, I will provide a URL that will take you to the project to complete.  Once you have completed the coding project(s) (you have unlimited attempts), you will download the Report from the Code Check website and upload this zipped file(s) to this Assignment folder.  Inside this zipped file will be your completed code and your *calculated score based on testing.  You may use your IDE (jGrasp/Eclipse) to write the code and then copy and paste over to Code Check, if desired.

*The calculated score will be located at the bottom of your submission in the form of (for example) “5/5 = 100%”, “4/5 = 80%”, “3/5 = 60%”, etc.  IF YOU DO NOT obtain 100%, I encourage you to reach out for help on the Problem & Solutions Blog with your error messages so others can help.  You can also view the “Common Code Check Errors” document located in iCollege.  Please make sure you have viewed the “How to Use Code Check” video before starting.

Description of Project 2 Purpose:

In this project, we will prompt the user to enter the number of students and each student’s name and score and output the name and score of the top (“highest”) student.  We will use while loops to validate input for a “score” to ensure it meets the requirements.  We will use a for loop to read in a series of student names and scores (other than the 1st student we store as our starting point) and use an if statement to determine if a newer score entered is now the “highest” score.  If it is, then we will need to update our “highest” student.

Please see the Sample Outputs below to see how we will prompt and obtain user input and where there is a validation of an incorrect score.

Decisions and Loops

The following are sample runs of the program to help you write your code and format your output.  Your output must match the Sample Output exactly or it will not pass.  Please pay attention to the format of string prompts, blank lines, and output.

Sample Output 1:

Enter the number of students: 0            <– Red indicates user/test input to promptsNumber of students must be at least 1Please renter number of students >> 1      <– Notice the format of prompt with >> – match exactlyEnter a student name: GreggEnter a student score: 85.4Top student Gregg’s score is 85.4             <– Output of “highest” student

Sample Output 2:

Enter the number of students: 2Enter a student name: ValerieEnter a student score: -14                  <– Validating input with while loopScore cannot be negative                    <– Outputting error message before re-promptPlease renter the student score >> 65.4     <– Prompt again to obtain new scoreEnter a student name: VladimerEnter a student score: 78.4Top student Vladimer’s score is 78.4                    <– Output of “highest” studentSample Output 3:Enter the number of students: 3Enter a student name: ChristopherEnter a student score: 81.5Enter a student name: JeremiahEnter a student score: -40Score cannot be negative                  <– Validating input with while loop (this is inside FOR loop)Please renter the student score >> -2     <– Obtain new scoreScore cannot be negativePlease renter the student score >> 87     <– Validating input again! This is why we need a while loop and not if/elseEnter a student name: GhulamEnter a student score: 78.9Top student Jeremiah’s score is 87.0

Instructions Project 2:

  1. Go to the following URL to complete the program: Project 2
  2. Using an IDE (jGrasp or Eclipse first), create a new class file named StudentScores.Javascript (I recommend starting in your IDE so you know how to use it!)
  3. You will be filling in code everywhere you see the ellipses (. . .) in the Code Check code.  Please follow the instructions and use the Sample Outputs to guide you.
  4. Write the Class comment and @author and @version tags
  5. Prompt the user to enter the number of students and store input in a variable.

    • Using a while loop, validate the input to make sure it is at least 1.
    • Inside the while loop, (1) output the error message and (2) re-prompt the user and store the new input in your variable. **Watch the Lecture Video: While Loops in Ch. 4. (See also p. 169 4.7.4 – similar to this and p. 118 3.8).
  6. Prompt the user to enter a student’s name and store input in a variable (such as topStudent) We won’t validate as anything can be accepted as a String.
  7. Prompt the user to enter a student’s score and store input in a variable (such as topScore).

    • Using a while loop, validate the input to make sure it is non-negative.
    • Inside the while loop, (1) output the error message and (2) re-prompt the user and store the new input in your variable (much like Step 5).
  8. Now we will use a for loop (SEE Step 9 – Step 8 is explanation of what will happen in Step 9) to read in the remaining students if there is more than one student (if not, then we know the “highest” score). **Please note: We will be temporarily storing the remaining student’s names and scores as we compare it to our first student’s score to see if it is higher.

    • EX:  Suppose our first student is “Ann” with a score of “87.2”.  Inside the for loop, we will prompt for another student name and a score, validate, and then use an if statement to see if the score is higher than the first student.  If it is, we will need to replace our “highest” student name and score with the other student.  So if “Miquel” is the second student’s name and his score is “92.5”, Miquel is now the “highest” or top student.
  9. Write a for loop that starts counting at 0 and goes up to the number of students – 1 (because we have already stored the 1st student in Steps 6 & 7) You can use your number of students variable from Step 5.

    • Inside the for loop,

      1. Prompt for the student name and store the input in a variable (See Sample Output)
      2. Prompt for the student score and store the input in a variable (make sure to validate score with a while loop here just as you did in Step 7 – i.e. it must be non-negative)
      3. Still inside the for loop (but not while loop), use an if statement to test if the new score inputted is greater than the 1st student’s score you found in Step 7.  If it is, replace the “top” student’s name and score with the new student.  (Since this student is now the highest, we do not need to retain the 1st student anymore.  This will overwrite it.  We will continue this way until all names and scores are entered.)
      4. Close the if statement and for loop  (make sure you have closing } for all blocks opened)
  10. Use a println statement to output the Top student’s name and score (See Sample Output for formatting).
  11. Submit your code in Code Check and check the tests and Checkstyle and correct any error messages or output formatting issues.
  12. Once you have everything correct, download the zipped file and then upload to this Assignment folder.  You should see a “Download” button that looks like this that will give you a zipped file containing your code and test data:

Testing and Submitting

Once you have thoroughly tested your program, please upload the zipped file only to this Ch. 3 & 4 Programming Assignment folder.

You will be graded on:

  1. Neatness of code and use of proper indentation of 4 spaces, 8 spaces, etc.  This is the Checkstyle part of your Report.
  2. Commenting of code – including class comment, @author, @version, and code comments. This is the Checkstyle part of your Report.
  3. Good use of constant and variable names – they should be descriptive names and not individual characters or abbreviations.  Ex.  FINAL_COST or firstName. This is the Checkstyle part of your Report.
  4. Output is correct and matches the Sample Output for all tests that executed on your code in Code Check.  This is the Test 1, Test 2, etc. part of your Report.  They must say “Pass”.
  5. Correct calculations using variables and constants (i.e. the math is correct).  This is the Test 1, Test 2, etc. part of your Report.
  6. My visual inspection of your code.  I will be checking for good variable and constant names and well as good indenting of code.  Instructor reserves the right to make adjustments to the Code Check score based on inspection.

ALL DONE!!  Great job!

Code check link.

https://codecheck.it/files/21060618537x59n66mvc9icgu33g7ukngdy