Question

In: Computer Science

Design a solution that requests and receives student names and an exam score for each. Use...

Design a solution that requests and receives student names and an exam score for each. Use one-dimensional arrays to solve this.

  • The program should continue to accept names and scores until the user inputs a student whose name is “alldone”.
  • After the inputs are complete determine which student has the highest score and display that student’s name and score.
  • Finally sort the list of names and corresponding scores in ascending order.

When you are done, printout the Code and, also the corresponding output produced. Upload both the txt file and the console output showing that your program run correctly.

Sample Input:

John   69

Alex 89

Billy 72

Sam   59

Serena 96

Alldone

Sample Output:

The student with the highest score is Serena with a score of 96

Sorted list

Serena 96

Alex 89

Billy 72

John   69

Sam   59

Please Write In JAVA Script

Thank you

Solutions

Expert Solution

import java.util.Scanner;

class Main {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

String name[] = new String[100];

Double marks[] = new Double[100];

int a =0;

do{  

  // Getting student name from user

     name[a] = input.next();

// Getting student name from user

marks[a] = input.nextDouble();

a++;

}while(name[a] == "alldone");

//Sorting the marks using bubble sort techinique

int n = marks.length; // stores the length of the array

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

for (int j = 0; j < n-i-1; j++)

if (marks[j] > marks[j+1])

{

// swaping both the terms

double temp = marks[j];

marks[j] = marks[j+1];

marks[j+1] = temp;

//swapping the corresponding names

String tempStr = name[j];

name[j] = name[j+1];

name[j+1] = tempStr;

}

//after bubble sort, the highest element gets placed at the end of the array

System.out.println("The student with the highest score is "+name[n-1]+" with a score of "+marks[n-1]);

System.out.println("Sorted list");

//printing the sorted list

for(int q = 0 ;q < n ;q++)

System,out.println(name[q] + " " + marks[q]);

}

}

The code produces the following output


Related Solutions

The score of a student on a certain exam is represented by a number between 0...
The score of a student on a certain exam is represented by a number between 0 and 1. Suppose that the student passes the exam if this number is at least 0.55. Suppose we model this experiment by a continuous random variable X, the score, whose probability density function is given by f(x) = { x if 0 <= x < 0.5 5x - 2 if 0.5 <= x <= 1 0 otherwise } a. What is the probability that...
1. You have data on two variables: exam score and student preparation time for the exam...
1. You have data on two variables: exam score and student preparation time for the exam in hours. You collect data from 6 students. (8 Points) Student Exam Prep Time (hours) Exam Score Student Exam Prep Time (hours) Exam Score 1 2 61 2 6 92 3 9 95 4 4 80 5 5 78 6 3 68 a. What will be the dependent variable and the independent variable? b. Construct a Scatter Plot. c. What type of relationship do...
Ms. Gibbs’ 6th period chapter eight exam Student Name Exam Score Robert Johnson 76 LaDavia Abrams...
Ms. Gibbs’ 6th period chapter eight exam Student Name Exam Score Robert Johnson 76 LaDavia Abrams 42 Jacobo Indiano 91 Johnathan Espy 95 Thomas Hartman 43 Stephanie Millerman 56 Alexis Abellan 46 William Press 85 John Mitchell 24 Brian Russell 25 Lisa Owens 60 Josue Alvarado 97 Alice Hsu 71 Raul Barrueco 99 Kathleen Drude 74 William Fritsche 90 Dwight Hare 72 Tommie Walker 92 Yolanda Pollard 68 Frank Bruscato 61 Larry Smith 85 Tonya Lumadue 53 Clifton Webb 81...
2. The pharmacist at Arnold Palmer Hospital, Wende Huehn-Brown, receives 13 requests for prescriptions each hour,...
2. The pharmacist at Arnold Palmer Hospital, Wende Huehn-Brown, receives 13 requests for prescriptions each hour, Poisson distributed. It takes her a mean time of 4 minutes to fill each, following a negative exponential distribution. Use the waiting-line table, Table D.5 (select the closest matching value) and Wq=Lq/λ, to answer these questions. a. What is the average number of prescriptions in the queue? b. How long will the average prescription spend in the queue? c. Wende decides to hire a...
The following data set shows the entrance exam score​ (Verbal GMAT) for each of eight MBA...
The following data set shows the entrance exam score​ (Verbal GMAT) for each of eight MBA students along with his or her grade point average​ (GPA) upon graduation. Gmat- 310, 290, 270, 290, 360, 280, 300, 290 Gpa- 3.7, 3.1, 3.1, 3.2, 3.9, 2.9, 3.6, 3.1 A linear regression on the data gives the equation below. Predicted GPA=−0.022695+0.011206(GMAT) Complete the parts below. a. Calculate the SST. a) Calculate the SST. ​(Round to three decimal places as​ needed.) b) Calculate the...
The following data set shows the entrance exam score​ (Verbal GMAT) for each of eight MBA...
The following data set shows the entrance exam score​ (Verbal GMAT) for each of eight MBA students along with his or her grade point average​ (GPA) upon graduation. Calculate the slope and​ y-intercept for the linear regression equation for these data. Calculate the slope and​ y-intercept for the linear regression equation for these data GMAT   GPA 310   3.6 300   2.9 260   3.1 290   3.1 340   3.9 270   3.1 290   3.7 310   3.1
A loan company wants to design a database to track student loans. Each student attending school...
A loan company wants to design a database to track student loans. Each student attending school is eligible for a loan. A student may have more than one loan. A student may be registered, possibly at different times, in more than one school. Each loan should belong to only one bank. Each bank can approve as many loans as it desires. For each loan, the loan company will track: the student’s SSN, name, address, amount of loan, date of the...
A loan company wants to design a database to track student loans. Each student attending school...
A loan company wants to design a database to track student loans. Each student attending school is eligible for a loan. A student may have more than one loan. A student may be registered, possibly at different times, in more than one school. Each loan should belong to only one bank. Each bank can approve as many loans as it desires. For each loan, the loan company will track: the student’s SSN, name, address, amount of loan, date of the...
An exam has 5 questions and each of them has 4 possible answers. A student gets...
An exam has 5 questions and each of them has 4 possible answers. A student gets 3 points for each correct answer and loses 1 point for each wrong answer. Consider a student who answers all questions completely at random. Let X denote the number of correct answers and Y the number of points of this student at the end of the test. (A negative score is possible). (a) Compute the mean and the standard deviation of Y , µY...
Write a java code that gets student test scores from the user. Each test score will...
Write a java code that gets student test scores from the user. Each test score will be an integer in the range 0 to 100. Input will end when the user enters -1 as the input value. After all score have been read, display the number of students who took the test, the minimum score, the maximum score, the average score (with decimal point, and the number of A where an A is a score in the range 90-100.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT