Question

In: Computer Science

java programming write a program with arrays to ask the first name, last name, middle initial,...

java programming

write a program with arrays to ask the first name, last name, middle initial, IDnumber and 3 test scores of 10 students.

calculate the average of the 3 test scores. show the highest class average and the lowest class average. also show the average of the whole class.

please use basic codes and arrays with loops the out put should look like this:

sample output

first name middle initial last name    ID    test score1 test score2 test score3

dhdh d djddj. 3456 20    80. 67

the class average is 80

the highest class average is80

the lowest class average is 80

please use printf to format the output

Solutions

Expert Solution

import java.util.*;


class Arrays
{
   public static void main (String[] args)
   {
       Scanner input = new Scanner(System.in);
      
       double[] testScore = new double[3];
       String[] firstName = new String[10];
       String[] lastName = new String[10];
       String[] middleInitial = new String[10];
       int[] idNum = new int[10];
       double[] avg = new double[10];
       double highest,lowest,average;
       highest = 0;
       lowest = 999;
       average = 0;
      
       System.out.println("Enter the number of students : ");
       int n = input.nextInt();
      
       for(int i=0;i<n;i++)
       {
       System.out.println("Enter first name : ");
       firstName[i] = input.next();
       System.out.println("Enter middle initial : ");
       middleInitial[i] = input.next();
       System.out.println("Enter last name :");
       lastName[i] = input.next();
       System.out.println("Enter Id Number : ");
       idNum[i] = input.nextInt();
      
       System.out.println("Enter the three test scores of the student : ");
       for(int j=0;j<3;j++)
       {
       testScore[j] = input.nextDouble();
       avg[i] = avg[i] + testScore[j];
       }
      
       avg[i] = avg[i]/3;
       if(highest < avg[i])
       highest = avg[i];
       if(lowest > avg[i])
       lowest = avg[i];
       average = average + avg[i];
      
       }
      
       average = average/n;
   System.out.printf("\nThe class average is %.2f", average);
   System.out.printf("\nThe highest class average is %.2f",highest);
   System.out.printf("\nThe lowest class average is %.2f",lowest);
      
   }
}

Output:

Enter the number of students : 5
Enter first name : Garry 
Enter middle initial : G. 
Enter last name :Trump 
Enter Id Number : 1001 
Enter the three test scores of the student : 80 94 95 
Enter first name :  Bran 
Enter middle initial : A. 
Enter last name :Aniston 
Enter Id Number : 1003 
Enter the three test scores of the student : 60 90 95 
Enter first name : Adam 
Enter middle initial : K. 
Enter last name :Lawrence 
Enter Id Number : 1002 
Enter the three test scores of the student : 70 90 95 
Enter first name : Anish 
Enter middle initial : L. 
Enter last name :Gupta 
Enter Id Number : 1004 
Enter the three test scores of the student : 90 90 95 
Enter first name : Smith 
Enter middle initial : K. 
Enter last name :Cooper 
Enter Id Number : 1005 
Enter the three test scores of the student : 80 60 55 

The class average is 82.60
The highest class average is 91.67
The lowest class average is 65.00

Do ask if any doubt. Please upvote.


Related Solutions

Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name, that does the following: Create two arrays that will hold related information. You can choose any information to store, but here are some examples: an array that holds a person's name and an array that hold's their phone number an array that holds a pet's name and an array that holds what type of animal that pet is an array that holds a student's...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name, that does the following: Declare an array reference variable called myFavoriteSnacks for an array of String type. Create the array so that it is able to hold 10 elements - no more, no less. Fill the array by having each array element contain a string stating one of your favorite foods/snacks. Note: Only write the name of the snack, NO numbers (i.e. Do not...
PYTHON Modify the program in section Ask the user for a first name and a last...
PYTHON Modify the program in section Ask the user for a first name and a last name of several people.  Use a loop to ask for user input of each person’s first and last names  Each time through the loop, use a dictionary to store the first and last names of that person  Add that dictionary to a list to create a master list of the names  Example dictionary: aDict = { "fname":"Douglas", "name":"Lee" } ...
How do I get the first initial of a first, middle, and last name? Also when...
How do I get the first initial of a first, middle, and last name? Also when I look to count characters in the name I want to be abel to count the spaces in-between the names how can i do this?
write a regular expression that will, using capturing groups, find: last name first name middle name...
write a regular expression that will, using capturing groups, find: last name first name middle name (if available) student ID rank home phone work phone (if available) email program (i.e., S4040) grade Replace the entire row with comma-delimited values in the following order: first name,middle name,last name,program,rank,grade,email,student ID,home phone,work phone Example substitution string for the first student Jane,V,Quinn,S4040,SO,B,[email protected],Q43-15-5883,318-377-4560,318-245-1144,Y
You have been asked to write program that allows the user to input a first name, middle initial (without the period)
You have been asked to write program that allows the user to input a first name, middle initial (without the period), and last name of a user and then display that person’s name with the first, middle initial followed by a period, and last name last.BEFORE creating the program, use structured programming principles to document how you are going to develop the program. Use Microsoft Word to complete this part of the assessment. Answer each of the following areas:Solve a...
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...
C++ Write a program that asks a teacher to input a student’s first name, last name,...
C++ Write a program that asks a teacher to input a student’s first name, last name, and four test scores. The program should find the average of the four test scores and should then write the following information to a file named “students.txt” last_name first_name average A student's first name of “XX” should be used as a sentinel value and no numeric grades less than 0 or greater than 100 should be accepted.  The program should then read the information in...
Write a program that utilizes a Professor class. A professor has a first name, last name,...
Write a program that utilizes a Professor class. A professor has a first name, last name, affiliation, easiness grade, and a helpfulness grade. Grades range from 1 (lowest) to 5 (highest). The Professor class has two constructors. The first constructor initiates the object with just the first name, the last name, and the affiliation. The default value for easiness and helpfulness grade is 3. The second constructor initiates the object using the first name, the last name, the affiliation, and...
Write a Java program to do the following: Ask the user to enter 10 first names...
Write a Java program to do the following: Ask the user to enter 10 first names (one word - no hyphen or apostrophe) using the keyboard. 1) Display the list of names one per line on the Console. 2) Display the names again, after eliminating duplicates using a HashSet (Your code MUST use HashSet).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT