Write a program which keeps track of scores for three test for a class of unknown number of students. Your program can assume that when receiving information scores for all 3 tests will be received at the same time. Your program should be able to have a user enter test scores, load test scores from a file, save them to a file, display test scores, provide the average score for a particular test and an average score across the 3 tests for a particular student. Your program must also utilize a menu which runs until told to quit. To accomplish this you will need 3 arrays where each array represents scores for one test and the index locations for the arrays will correspond with one student. For example, to refer to the test score for the 3rd test for student 7 you would call test3[7]. You can assume in your program that a user will not enter scores for more than 100 students.
1
Expert's answer
2012-06-12T07:02:28-0400
import java.io.*; import java.util.Scanner;
public class Test { private static int[] test1 = new int[100]; private static int[] test2 = new int[100]; private static int[] test3 = new int[100]; private static int[] average = new int[100]; private static Scanner sc = new Scanner(System.in);
public static void main(String[] args) throws IOException { & System.out.print("Do you want enter score(1) or read from file(2): "); & int choice = sc.nextInt(); & boolean status = true; & switch (choice) { case 1: while(status){ & enterScore(); & System.out.println("Do you want enter score of other student? (1 - yes, 2 - no)"); & choice = sc.nextInt(); & if(choice == 1){ status = true; & } & if(choice == 2){ status = false; & } } break; case 2: readFromFile(); break; & } & while(true){ System.out.println("1. Enter other student\n"+"2. Display all scores\n"+"3. Save score into file\n"+ & quot;4. Display average score\n"+"5. Exit\n"); choice = sc.nextInt(); switch (choice) { case 1 : enterScore(); & break; case 2 : displayAll(); & break; case 3 : saveScore(); & break; case 4 : displayAverage(); & break; case 5 : System.exit(0); & break; } & } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment