noobzor
10-31-2007, 02:52 AM
hi
I need to create a program that uses JOptionPane to put in 8 persons name,8 ID, and 3 grade exams, with 8 each.I need to also get the final grade of the 3 exams. ALso i need to sort arrays from highest to lowest. Find the highest score in exam 2, average score in exam3, and the average grade of the final exam.
here is what i have so far
import javax.swing.*;
public class Gradessss
public static void main(String[] args)
{
//declare arrays, their types, and load them
String[]course = {"CIT111_01"};
String stu_id;
String lastName;
int exam1[] = {50, 75, 97, 37, 78, 88, 55, 97};
int exam2[] = {90, 34, 85, 88, 78, 99, 55, 37};
int exam3[] = {75, 20, 90, 78, 78, 88, 99, 55};
double[] finalgrade = new double[8];
int x;
//last name
//print out last name, course grade
//lowest score in exam1 (of all grades)
//highest score in exam2
//average score in exam3
//highest lowest average final grade
//find all grades but name for location 4
//print out array location 4:array location(4) is exam(4)
//locateLastName(Lastname);
//public static void locateLastName(String lastName)
//{
//for
//if(lastName(x)== "Golling")
//system.out
//lastname(x) finalgrade(x)
for (x = 0; x < 8; x++)
{
int v = 0;
String[] last = new String[8];
lastName = JOptionPane.showInputDialog(null, "Enter 8 last names");
last[1] = lastName;
exam1 = JOptionPane.showInputDialog(null, "Enter the grade for the first exam");
exam1[i] = Integer.parseInt(exam2);
exam2 = JOptionPane.showInputDialog(null, "Enter the grade for the first exam");
exam2[i] = Integer.parseInt(exam2);
exam3 = JOptionPane.showInputDialog(null, "Enter the grade for the first exam");
exam3[i] = Integer.parseInt(exam3);
String[] id = new String[8];
stu_id = JOptionPane.showInputDialog(null, "enter 8 student IDs");
id[1] = stu_id;
double finalGrade = (exam1[x] + exam2[x] + exam3[x]) / 3;
System.out.println("The arrays are:\n" + x + "course :" + "\texam1:"
+ exam1[x] + exam2[x]+ exam3[x] + finalGrade);
int comparison1 = exam1.length - 1;
for(int a = 0; a < exam1.length - 1; ++a)
{
for(int b = 0; b < comparison1; ++b)
{
if(exam1[b] > exam1[b + 1])
{
int temp = exam1[b];
exam1[b] = exam1[b + 1];
exam1[b + 1] = temp;
}
}
}
System.out.println("Lowest grade in Exam 1 is: " + exam1[0]);
int comparison2 = exam2.length - 1;
for(int a = 0; a < exam2.length - 1; ++a)
{
for(int b = 0; b < comparison2; ++b)
{
if(exam2[b] < exam2[b + 1])
{
int temp = exam2[b];
exam2[b] = exam2[b + 1];
exam2[b + 1] = temp;
}
}
}
System.out.println("Highest grade in Exam 2 is: " + exam2[0]);
double aveExam3 = (exam3[0] + exam3[1] + exam3[2] + exam3[3] + exam3[4] +
exam3[5] + exam3[6] + exam3[7]) / 8;
System.out.println("Average score of Exam 3 is: " + aveExam3);
double aveFinalExam = (finalExam[0] + finalExam[1] + finalExam[2] + finalExam[3] + finalExam[4] +
finalExam[5] + finalExam[6] + finalExam[7]) / 8;
System.out.print("Average grade of Final Exams is: " + aveFinalExam);
double comparisonFinLow = finalExam.length - 1;
for(double c = 0; c < finalExam.length - 1; ++c)
{
for(double d = 0; d < comparisonFinLow; ++d)
{
if(finalExam[d] > finalExam[d + 1])
{
double temp = finalExam[d];
finalExam[d] = finalExam[d + 1];
finalExam[d + 1] = temp;
}
}
}
//System.out.println("");
int comparisonFinHi = finalExam.length - 1;
for(int a = 0; a < finalExam.length - 1; ++a)
{
for(int b = 0; b < comparisonFinHi; ++b)
{
if(finalExam[b] < finalExam[b + 1])
{
int temp = finalExam[b];
finalExam[b] = finalExam[b + 1];
finalExam[b + 1] = temp;
}
}
}
//System.out.println("");
System.exit(0);
}
}
I need to create a program that uses JOptionPane to put in 8 persons name,8 ID, and 3 grade exams, with 8 each.I need to also get the final grade of the 3 exams. ALso i need to sort arrays from highest to lowest. Find the highest score in exam 2, average score in exam3, and the average grade of the final exam.
here is what i have so far
import javax.swing.*;
public class Gradessss
public static void main(String[] args)
{
//declare arrays, their types, and load them
String[]course = {"CIT111_01"};
String stu_id;
String lastName;
int exam1[] = {50, 75, 97, 37, 78, 88, 55, 97};
int exam2[] = {90, 34, 85, 88, 78, 99, 55, 37};
int exam3[] = {75, 20, 90, 78, 78, 88, 99, 55};
double[] finalgrade = new double[8];
int x;
//last name
//print out last name, course grade
//lowest score in exam1 (of all grades)
//highest score in exam2
//average score in exam3
//highest lowest average final grade
//find all grades but name for location 4
//print out array location 4:array location(4) is exam(4)
//locateLastName(Lastname);
//public static void locateLastName(String lastName)
//{
//for
//if(lastName(x)== "Golling")
//system.out
//lastname(x) finalgrade(x)
for (x = 0; x < 8; x++)
{
int v = 0;
String[] last = new String[8];
lastName = JOptionPane.showInputDialog(null, "Enter 8 last names");
last[1] = lastName;
exam1 = JOptionPane.showInputDialog(null, "Enter the grade for the first exam");
exam1[i] = Integer.parseInt(exam2);
exam2 = JOptionPane.showInputDialog(null, "Enter the grade for the first exam");
exam2[i] = Integer.parseInt(exam2);
exam3 = JOptionPane.showInputDialog(null, "Enter the grade for the first exam");
exam3[i] = Integer.parseInt(exam3);
String[] id = new String[8];
stu_id = JOptionPane.showInputDialog(null, "enter 8 student IDs");
id[1] = stu_id;
double finalGrade = (exam1[x] + exam2[x] + exam3[x]) / 3;
System.out.println("The arrays are:\n" + x + "course :" + "\texam1:"
+ exam1[x] + exam2[x]+ exam3[x] + finalGrade);
int comparison1 = exam1.length - 1;
for(int a = 0; a < exam1.length - 1; ++a)
{
for(int b = 0; b < comparison1; ++b)
{
if(exam1[b] > exam1[b + 1])
{
int temp = exam1[b];
exam1[b] = exam1[b + 1];
exam1[b + 1] = temp;
}
}
}
System.out.println("Lowest grade in Exam 1 is: " + exam1[0]);
int comparison2 = exam2.length - 1;
for(int a = 0; a < exam2.length - 1; ++a)
{
for(int b = 0; b < comparison2; ++b)
{
if(exam2[b] < exam2[b + 1])
{
int temp = exam2[b];
exam2[b] = exam2[b + 1];
exam2[b + 1] = temp;
}
}
}
System.out.println("Highest grade in Exam 2 is: " + exam2[0]);
double aveExam3 = (exam3[0] + exam3[1] + exam3[2] + exam3[3] + exam3[4] +
exam3[5] + exam3[6] + exam3[7]) / 8;
System.out.println("Average score of Exam 3 is: " + aveExam3);
double aveFinalExam = (finalExam[0] + finalExam[1] + finalExam[2] + finalExam[3] + finalExam[4] +
finalExam[5] + finalExam[6] + finalExam[7]) / 8;
System.out.print("Average grade of Final Exams is: " + aveFinalExam);
double comparisonFinLow = finalExam.length - 1;
for(double c = 0; c < finalExam.length - 1; ++c)
{
for(double d = 0; d < comparisonFinLow; ++d)
{
if(finalExam[d] > finalExam[d + 1])
{
double temp = finalExam[d];
finalExam[d] = finalExam[d + 1];
finalExam[d + 1] = temp;
}
}
}
//System.out.println("");
int comparisonFinHi = finalExam.length - 1;
for(int a = 0; a < finalExam.length - 1; ++a)
{
for(int b = 0; b < comparisonFinHi; ++b)
{
if(finalExam[b] < finalExam[b + 1])
{
int temp = finalExam[b];
finalExam[b] = finalExam[b + 1];
finalExam[b + 1] = temp;
}
}
}
//System.out.println("");
System.exit(0);
}
}