Question

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

java programming

write a program with arrays to ask the first name, middle initial, last name and id# 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

please use printf to format output

sample output

First name MI    Last name    ID# Test1    Test2 Test 3    Average

Sid    s jacobs    a999 90    90    90    90

Mike f    scott    b999 80    80    80    80

The class average is 90

the highest average is 90

the lowest average is 90

Please input for 10 students

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Java Program:

import java.util.Scanner;

public class StudentTest {

   public static void main(String[] args) {
       // Scanner class object to read input
       Scanner scan = new Scanner(System.in);
      
       //array declarations
       String[] firstName = new String[10];
       String[] middileInitial = new String[10];
       String[] lastName = new String[10];
       String[] ID = new String[10];
       float[][] testScores = new float[10][3];
       float[] average = new float[10];
      
       //variables to calcualte averages
       float classAvg = 0;
       float highestAvg = 0;
       float lowestAvg = 0;
      
       //loop to enter for 10 students
       for(int i=0;i<10;i++) {
           System.out.print("Enter your first name:");
           firstName[i] = scan.next();
          
           System.out.print("Enter your middle initial:");
           middileInitial[i] = scan.next();
          
           System.out.print("Enter your last name:");
           lastName[i] = scan.next();
          
           System.out.print("Enter your ID#:");
           ID[i] = scan.next();
          
           float sumTestScores = 0;
           //asking 3 test scores
           for(int j=0;j<3;j++) {
               System.out.print("Test"+(j+1)+":");
               testScores[i][j] = scan.nextInt();
              
               //adding up 3 test scores
               sumTestScores = sumTestScores + testScores[i][j];
           }
          
           //for calculating average of 3 test scoresW
           average[i] = (float)sumTestScores/3;
          
           //for calculating highest average
           if(average[i] > highestAvg) {
               highestAvg = average[i];
           }
          
           //for calculating lowest average
           if(i>0) {
               if(lowestAvg > average[i]) {
                   lowestAvg = average[i];
               }
           }else {
               lowestAvg = average[i];
           }
           System.out.print("\n");
       }

       //displaying output to consolse
       System.out.printf("First name\tMI\tLast name\tID#\tTest1\tTest2\tTest3\tAverage\n");
       for(int i=0;i<10;i++) {
                      
           System.out.printf("%s\t\t%s\tt%s\t%s\t",firstName[i],middileInitial[i],lastName[i],ID[i]);
          
           //to display test scores
           for(int j=0;j<3;j++) {
               System.out.printf("%.2f\t",testScores[i][j]);

classAvg = classAvg + testScores[i][j]; //calculating the class average
           }
           System.out.printf("%.2f",average[i]);
           System.out.print("\n");          
       }

       //to display averages
       System.out.printf("The class average is %.2f",classAvg);
       System.out.printf("\nThe highest average is %.2f",highestAvg);
       System.out.printf("\nThe lowest average is %.2f",lowestAvg);
   }

}
Output:

Console 3 <terminated> StudentTest [Java Application] C:\Program Files\Java\jre1.8.0_221\bin\javaw.exe (Aug 7, 2019, 12:06:11 AM) Enter your first name: Sid Enter your middle initial:s Enter your last name: Enter your ID#: a999 Test1:90 Test2:90 Test3:90 Enter your first name:Mike Enter your middle initial:f Enter your last name: scott Enter your ID# : b999 Test1:80 Test2:80 Test3:80 First name Last name Test2 MI ID# Test1 Test3 Average jacobs a999 Sid 90.00 90.00 90.00 90.00 Mike f b999 80.00 80.00 scott 80.00 80.00 The class average is 0.00 The highest average is 90.00 The lowest average is 80.00

Add a comment
Know the answer?
Add Answer to:
java programming write a program with arrays to ask the first name, middle initial, last name...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • need to be solved including (using namespace std) and without using arrays Problem: Write a CH...

    need to be solved including (using namespace std) and without using arrays Problem: Write a CH program that considers many students (the number of students is given as an input to the program by the user). For each student the program allows the user to input the ID of the student (as integer number), the student gender (one character M for male and F for female), and grades of 2 tests (a Test grade is a value between 0 and...

  • Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

    Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...

  • use  JOptionPane to display output Can someone please help write a program in Java using loops, not...

    use  JOptionPane to display output Can someone please help write a program in Java using loops, not HashMap Test 1 Grades After the class complete the first exam, I saved all of the grades in a text file called test1.txt. Your job is to do some analysis on the grades for me. Input: There will not be any input for this program. This is called a batch program because there will be no user interaction other than to run the program....

  • Create the program in C++ please. The new operator as outlined in 10.9 . Create a...

    Create the program in C++ please. The new operator as outlined in 10.9 . Create a Test class that includes the following Data members • First Name, last name, test1, test2, test3 o Methods • Accessor methods for each of the data members' • Mutator methods for each of the data members . A Default Constructor . A constructor that will accept arguments for each of the 5 data members • A method that will calculate the average of the...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes...

    CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes the user and displays the purpose of the program. It then prompts the user to enter the name of an input file (such as scores.txt). Assume the file contains the scores of the final exams; each score is preceded by a 5 characters student id. Create the input file: copy and paste the following data into a new text file named scores.txt DH232 89...

  • THIS IS FINAL COURSE ASSIGNMENT, PLEASE FOLLOW ALL REQUIREMENTS. Hello, please help write program in JAVA...

    THIS IS FINAL COURSE ASSIGNMENT, PLEASE FOLLOW ALL REQUIREMENTS. Hello, please help write program in JAVA that reads students’ names followed by their test scores from "data.txt" file. The program should output "out.txt" file where each student’s name is followed by the test scores and the relevant grade, also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in an instance of class variable of type...

  • First, create two inputs that can be stored in variables consisting of a student's name. When...

    First, create two inputs that can be stored in variables consisting of a student's name. When the program begins ask "Who is the first student?" followed by "Who is the second student?" You only have to have two students for this program. Ask the user for the scores for the last three test grades for each of the students .   After the user has entered both names, and three scores for each, the program should display the following as output:...

  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • Write a java program to create a student file which includes first name, last name, and...

    Write a java program to create a student file which includes first name, last name, and GPA. Write another Java program to open the students file. Display the students list and calculate the average GPA of the class.  

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT