Enter students name, press enter. Superwiz
Enter students id, press enter. 66666
Enter 4 test scores, press enter. 90 92 94 96
Enter students name, press enter. Top Gun
Enter students id, press enter. #1
Enter 4 test scores, press enter. 50 40 60 30
Enter students name, press enter. Darth Vader
Enter students id, press enter. r2d2
Enter 4 test scores, press enter. 80 100 40 95
Enter students name, press enter. Rock n roll
Enter students id, press enter. Music
Enter 4 test scores, press enter. 87 85 78 83
Enter students name, press enter. Go Rams
Enter students id, press enter. %$#@!
Enter 4 test scores, press enter. 76 75 74 73
*** The Echo data follows ***
Student Name ID# Test Scores
Superwiz 66666 90 92 94 96
Top Gun #1 50 40 60 30
Darth Vader r2d2 80 100 40 95
Rock n roll Music 87 85 78 83
Go Rams %$#@! 76 75 74 73
The student Superwiz, 66666 had the highest average of 93
The student Top Gun, #1 had the lowest average of 25
The class average is: 74.9
*** The list with letter grades follows ***
Student Name ID# Total Score Letter
Superwiz 66666 93.0 A
Top Gun #1 45.0 F
Darth Vader r2d2 78.75 C
Rock n roll Music 83.25 B
Go Rams %$#@! 74.5 C
Type add, delete, ascend or descend, press enter: Ascend (account for all human errors)
***The Ascending list follows ***
Student Name ID# Total Score Letter
Top Gun #1 45.0 F
Go Rams %$#@! 74.5 C
Darth Vader r2d2 78.75 C
Rock n roll Music 83.25 B
Superwiz 66666 93.0 A
Type add, delete, ascend or descend, press enter: Descend (account for all human errors)
***The Ascending list follows ***
Student Name ID# Total Score Letter
Superwiz 66666 93.0 A
Rock n roll Music 83.25 B
Darth Vader r2d2 78.75 C
Go Rams %$#@! 74.5 C
Top Gun #1 45.0 F
Are you done, type a Yes or a No Yes or No, press enter? Y e z
Oh Divine one please type a Yes or No, try again, press enter! N o
Type add, delete, ascend or descend, press enter: add (account for all human errors)
Enter students name, press enter. Butch Jr.
Enter students id, press enter. fun
Enter 4 test scores, press enter. 5 10 0 85
*** The Echo data follows ***
Student Name ID# Test Scores
Superwiz 66666 90 92 94 96
Top Gun #1 50 40 60 30
Darth Vader r2d2 80 100 40 95
Rock n roll Music 87 85 78 83
Go Rams %$#@! 76 75 74 73
Butch Jr. fun 5 10 0 85
The student Superwiz, 66666 had the highest average of 93
The student Butch Jr., fun had the lowest average of 25
The class average is: 66
Type add, delete, ascend or descend, press enter: delete (account for all human errors)
Enter Students name, press return. Top Gun
Enter students ID, press return. #1
** The Echo data follows **
Student Name ID# Test Scores
Superwiz 66666 90 92 94 96
Darth Vader r2d2 80 100 40 95
Rock n roll Music 87 85 78 83
Go Rams %$#@! 76 75 74 73
Butch Jr. fun 5 10 0 85
The student Superwiz, 66666 had the highest average of 93
The student Butch Jr., fun had the lowest average of 25
The class average is: 70
**************************************************************
**************************************************************
This is what my program does:
Welcome to GradeBook !!
How many students do you have, Enter a number(1-10) and press return.
5
Enter students name, press enter. Superwiz
Enter students id, press enter. 66666
Enter 4 test scores, press enter. 90 92 94 96
Enter students name, press enter. Top Gun
Enter students id, press enter. #1
Enter 4 test scores, press enter. 50 40 60 30
Enter students name, press enter. Darth Vader
Enter students id, press enter. r2d2
Enter 4 test scores, press enter. 80 100 40 95
Enter students name, press enter. Rock n roll
Enter students id, press enter. Music
Enter 4 test scores, press enter. 87 85 78 83
Enter students name, press enter. Go Rams
Enter students id, press enter. %$#@!
Enter 4 test scores, press enter. 76 75 74 73
*** The Echo data follows ***
Student Name ID# Test Scores
Superwiz 66666 90 92 94 96
Top Gun #1 50 40 60 30
Darth Vader r2d2 80 100 40 95
Rock n roll Music 87 85 78 83
Go Rams %$#@! 76 75 74 73
The student with the highest grade is 0
The student with the lowest grade is 0
So i need help with getting the student with the highest and lowest averages then the class average...Then i need to create functions for ascending order, descending order, adding someone, deleting someone... Here's my code....
*****************************************************
import java.util.*;
import java.io.*;
import java.text.DecimalFormat;
public class GradeBook
{
static int studCount = 0, numStudents, highStud, lowStud, studID;
static int fourTests[][];
static double testAvg[], classAvg;
static String studName[], studentID[];
public static void main(String[] args) throws IOException
{
GradeBookStart();
StudentInfo(numStudents, studCount);
EchoData();
highGrade();
lowGrade();
}
public static void GradeBookStart() throws IOException
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Welcome to teachers GradeBook !!");
System.out.println("How many students do you have? Enter a number(1-10) and press return. ");
numStudents = keyboard.nextInt();
studName = new String[numStudents];
fourTests = new int[numStudents][4];
studentID = new String[numStudents];
}
private static void StudentInfo(int numStudents, int studCount) throws IOException
{
do
{
Scanner keyboard = new Scanner(System.in);
System.out.println("\nEnter students name, press enter.");
studName[studCount] = keyboard.nextLine().trim();
studName[studCount] = studName[studCount].replace(" ", "");
System.out.println("enter students id, press enter.");
studentID[studCount] = keyboard.nextLine().trim();
studentID[studCount] = studentID[studCount].replace(" ", "");
for(int i=0;i<4;i++)
{
System.out.println("Enter test score #" + (i+1) + ", press enter");
fourTests[studCount][i] = keyboard.nextInt();
}
studCount++;
}while(studCount != numStudents);
}
private static void EchoData()
{
System.out.println("\n*** The Echo data Follows ***");
System.out.println("Student Name\tID#\tTest Scores");
for(int i = 0; i < numStudents; i++)
{
System.out.print(studName[i] + "\t" + studentID[i] + "\t");
for(int j=0;j<4;j++)
{
System.out.print(fourTests[i][j] + " ");
}
System.out.println();
}
System.out.println("The Student with the highest grade was " + highStud);
System.out.println("The Student with the lowest grade was " + lowStud);
}
private static int highGrade()
{
highStud = fourTests[0][0];
for ( int studentGrades[] : fourTests )
{
for ( int grade : studentGrades )
{
if ( grade > highStud )
highStud = grade;
}
}
return highStud;
}
private static int lowGrade()
{
int lowStud = fourTests[ 0 ][ 0 ];
for ( int studentGrades[] : fourTests )
{
for ( int grade : studentGrades )
{
if ( grade < lowStud )
lowStud = grade;
}
}
return lowStud;
}
}
This post has been edited by ProGraM: 20 January 2009 - 07:45 PM

New Topic/Question
Reply



MultiQuote





|