Question

In: Computer Science

Write a program in Java for: Starting a brand new term, you decide you want to...

Write a program in Java for:

Starting a brand new term, you decide you want to make a good impression on your instructor. To do this, you want to create an application that helps process midterm exam scores, letting the instructor know which student(s) earned the lowest score so the instructor can suggest some extra help resources.

To begin, initialize two parallel arrays (hardcoding the values):

  • Names: Joey, Lisa, Karen, Mark, Christopher, etc.
  • Scores: 78.5, 97.0, 42.5, 86.5, 42.5, etc.

Once you have initialized the parallel arrays with values, display the lowest score and the student(s) with that score. Note more than one student may be “tied” for the lowest score. Your application should handle this.

An example run of the program, assuming usage of the data identified above is:

Example Run:
The lowest midterm score was 42.5.

The student(s) that earned this score:

Karen

Christopher

The student(s) may benefit from extra help.

Note: Make sure your application uses good design practices, such as using methods other than main().

For output, you must use the JOptionPane class.

Solutions

Expert Solution

import javax.swing.JOptionPane;

public class findinglowestscore{
public static ArrayList<String> findnames(double[] marksarray,double lowestmarks,String[] namesarray)
{ArrayList<String> namesofstudents=new ArrayList<String>();
for(int i=0;i<marksarray.length;i++)
{if(marksarray[i]==lowestmarks)
namesofstudents.add(namesarray[i]);
  
}
return namesofstudents;
}
public static void main(String[] args){
String[] names=new String[] {"joey","Lisa","Karen","Mark","Christopher"};
double[] marks=new double[] {78.5,97.0,42.5,86.5,42.5};
double minmarks=Integer.MAX_VALUE;
for(int j=0;j<marks.length;j++)
{minmarks=Math.min(marks[j],minmarks);
  
}
  
ArrayList<String> name=findnames(marks,minmarks,names);
  
String s="";
for(String na:name)
s=s+na+"\n";
JOptionPane.showMessageDialog(null, "The lowest midterm score was"+minmarks+".\nThe student(s) that earned this score:\n"+s);
}

}


Related Solutions

I want to write this program in java. Write a simple airline ticket reservation program in...
I want to write this program in java. Write a simple airline ticket reservation program in java.The program should display a menu with the following options: reserve a ticket, cancel a reservation, check whether a ticket is reserved for a particular person, and display the passengers. The information is maintained on an alphabetized linked list of names. In a simpler version of the program, assume that tickets are reserved for only one flight. In a fuller version, place no limit...
Write a java program that asks the user for the starting X and Y position of...
Write a java program that asks the user for the starting X and Y position of a mouse cursor as well as the starting X and Y movement, then prints out its position until X < 0 or X >100 Example 2: Enter the starting X position: 60 Enter the starting Y position: 60 Enter the starting X velocity: 4.7 Enter the starting Y velocity: 1 X:60    Y:60 X:64.7 Y:61 X:69.4 Y:63 X:74.1 Y:65 X:78.8 Y:67 X:83.5 Y:69 X:88.2 Y:71...
What we want the program to do: We need to write a program, in Java, that...
What we want the program to do: We need to write a program, in Java, that will let the pilot issue commands to the aircraft to get it down safely on the flight deck. The program starts by prompting (asking) the user to enter the (start) approach speed in knots. A knot is a nautical mile and is the unit used in the navy and by the navy pilots. After the user enters the approach speed, the user is then...
Write a Java program that implements a queue in a hospital. I want your program to...
Write a Java program that implements a queue in a hospital. I want your program to ask the user to enter the number of patients then enter the patient number starting from 110 till the end of the queue then print number of patients waiting in the queue. Suppose you have a queue D containing the numbers (1,2,3,4,5,6,7,8), in this order. Suppose further that you have an initially empty Stack S. Give a code fragment that uses S, to store...
Create JAVA PROGRAM, and write comment for codes also. 3) You want to keep track of...
Create JAVA PROGRAM, and write comment for codes also. 3) You want to keep track of your progress towards running a 10K. There are two kinds of races - 5K and 10K. The program needs to ask what race was run and what the time was in seconds until the user quits. When they quit, display the average and best time for each type of race in minutes.
Write a JAVA program that allow a user to enter 2 number, starting point and end...
Write a JAVA program that allow a user to enter 2 number, starting point and end point. For example a user me enter 1 and 100. Your program will Add numbers from 1 to 100, add all the even number, and add all the odd numbers Output: The sum of number 1 to 100 is: The sum of even number 1 to 100 is: The sum of odd number 1 to 100 is:
Write a program in Java to: Ask the user how many scores they want to enter...
Write a program in Java to: Ask the user how many scores they want to enter (=> Create an array based the entered size) Ask the user to enter their scores in the quarter (Fill the array with the entered scores(assigned to elements)) ==>> Use a "for" loop Find the greatest score Calculate and show the average Show the final grade based on the average (For example A,B,C ... ) Print the scores (the elements of the array) => Use...
Write a Java program that will first ask the user how many grades they want to...
Write a Java program that will first ask the user how many grades they want to enter. Then use a do…while loop to populate an array of that size with grades entered by the user. Then sort the array. In a for loop read through that array, display the grades and total the grades. After the loop, calculate the average of those grades and display that average. Specifications Prompt the user for the number of grades they would like to...
in java pls Write a program for spiritual lumberjacks who want to show their appreciation for...
in java pls Write a program for spiritual lumberjacks who want to show their appreciation for each tree they 'kill' by celebrating its years of life. Ask the lumberjack how many trees he wants to cut. Verify you got the number correctly by printing it to output. Write a loop that iterates over all the trees the lumberjack wants to cut down. Print the tree number to the screen to make sure your loop is working correctly. Query the lumber...
Based on three criteria of Performance, Price, and Brand, we want to decide to by a...
Based on three criteria of Performance, Price, and Brand, we want to decide to by a computer. According to our preferences, the weights of the criteria are 0.581, 0.309, and 0.110, respectively. A study comparing three personal computers of hp. Asus, and Apple resulted in the following pairwise comparison matrix for the performance criterion: Apple 12 1/2 Performance ap Asus Apple Asus 3 1/3 1/2 According to the Analytical Hierarchy Process (AHP) method, (use three decimals in your calculations, for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT