menu
bartleby
search
close search
Hit Return to see all results

5-9) (Find the two highest scores) Write a program that prompts the user to enter the number of students and each student's name and score, and finally displays thestudent with the highest score and the student with the second-highest score.SAMPLE RUN #4: Java TwoHighestScoresStandard OutputHide InvisiblesEnter.the.number of students:Student.1.of.6+Enter student's.name: Enter.student's score: Student.2.of.6+Enter.student's name: Enter student's score:student 3.of.6+Enter student's name: Enter.student's score:Student.4 of.6Enter student's name: Enter student's.score:Student.5.of.6+Enter.student's name: Enter student's score:Student.6.of.6Enter student's.name: Enter.student's.score: The highest.score.was.96.7.and Thomas Collins got-itThe second highest.score was 93.3e.and.Amy Dickstein.got.it

Question

5-9) (Find the two highest scores)

Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score and the student with the second-highest score. 

5-9) (Find the two highest scores) Write a program that prompts the user to enter the number of students and each student's name and score, and finally displays the
student with the highest score and the student with the second-highest score.
SAMPLE RUN #4: Java TwoHighestScores
Standard Output
Hide Invisibles
Enter.the.number of students:Student.1.of.6+
Enter student's.name: Enter.student's score: Student.2.of.6+
Enter.student's name: Enter student's score:student 3.of.6+
Enter student's name: Enter.student's score:Student.4 of.6
Enter student's name: Enter student's.score:Student.5.of.6+
Enter.student's name: Enter student's score:Student.6.of.6
Enter student's.name: Enter.student's.score: The highest.score.was.96.7.and Thomas Collins got-it
The second highest.score was 93.3e.and.Amy Dickstein.got.it
help_outline

Image Transcriptionclose

5-9) (Find the two highest scores) Write a program that prompts the user to enter the number of students and each student's name and score, and finally displays the student with the highest score and the student with the second-highest score. SAMPLE RUN #4: Java TwoHighestScores Standard Output Hide Invisibles Enter.the.number of students:Student.1.of.6+ Enter student's.name: Enter.student's score: Student.2.of.6+ Enter.student's name: Enter student's score:student 3.of.6+ Enter student's name: Enter.student's score:Student.4 of.6 Enter student's name: Enter student's.score:Student.5.of.6+ Enter.student's name: Enter student's score:Student.6.of.6 Enter student's.name: Enter.student's.score: The highest.score.was.96.7.and Thomas Collins got-it The second highest.score was 93.3e.and.Amy Dickstein.got.it

fullscreen
check_circleAnswer
Step 1

Program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score and the student with the second-highest score. 

Step 2

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int n,first_highest_marks=0,second_highest_marks=0;

 String HighestStudentName="", Secondhighestname ="";

//displaying message to user to enter the total number of student

System.out.println("enter the total number of student:");

//taking input of total number of student by user

Scanner sc= new Scanner(System.in);

n=sc.nextInt();

//taking input of name and marks of student by the user

for(int i=1;i<=n;i++)

{

System.out.println("enter student name:");

String s=sc.next();

System.out.println("enter student marks");

int marks=sc.nextInt();

//comparing the marks of student

if(marks>first_highest_marks)

{

second_highest_marks=first_highest_marks;

first_highest_marks=marks;

Secondhighestname = HighestStudentName;

HighestStu...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: use java Develop a program which allows the user to enter numbers into an array. Input will be as fo...

A: Program plan:Import the required packages.Define a class named “ArraySort”.Define a “main()” method....

question_answer

Q: Prove that the following languages are not regular: (b) L = {anblak : k ≠ n + l}. (c) L = {anblak : ...

A: In the given question, multiple parts are there and we will solve only first three parts as no parti...

question_answer

Q: How do you convert 172.16.20.55 to binary format?

A: 172.16.20.55 represents IP address in decimal format. In order to convert it into binary format we n...

question_answer

Q: Hello,  I am trying to write a program in Pynthon. I do not know may be it is too much. Just need so...

A:  Program plan:Define a function named “main()”.Assign a file name or file path.Create an empty dicti...

question_answer

Q: Consider the following segment of code:procedure Mvar x: integer;procedure A (c: integer)var a, b: i...

A: Instructions for drawing the runtime stack (at “a:= c-d;”):The stack includes the activation records...

question_answer

Q: // java // book is starting out with java //chapter 12  (5)Theater RevenueA movie theater only keeps...

A: Program plan:Import required packages.Define a class named “TheatreGUI”.Declare the required variabl...

question_answer

Q: I need help with the SQL query for the following question: 1.  Get the total number of reviews of mo...

A: The details about the table are given with table name and different entities. Here the table name is...

question_answer

Q: Read in 5 letters from the keyboard, reverse the order of the second and next to last letters, and p...

A: Program to reading 5 letters from the keyboards and reversing the order of the second and next to la...

question_answer

Q: Hi, please do you help with questions of Python? If so, I need help with the following: Write a prog...

A: Program Instructions:Use range() to print from 1 to 25.Use end in print() function to print the valu...

Sorry about that. What wasn’t helpful?