By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,797 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,797 IT Pros & Developers. It's quick & easy.

Help With A Grading Program!!

P: 14
i am trying to created a program that will write a grading program for a class with the following policies

there are 2 quizzes each graded on the basis of 10 points
there is 1 midterm and 1 final each graded on 100 points
the final exam counts for 50% of the grade, the midterm counts for 25% and the 2 quizzes togehter count for a total of 25%(i have to normailze the scores)

letter grades based on
90-100 A
80-89 B
70-79 C
60-69 D
0-59 E
the program will read in the student's scores from a text file, and output the students record which will have the names 2 quiz, and 2 exam as well as the student's average numeric score for the enitre course.(all scores are intergers )
i want to use standard I/O
the following is the code i have come up with
Class grade{
public static void main(String[] args){

double quiz1, quiz2, midterm, final, average;

Scanner grades = new Scanner(System.in);

while(grades.hasNext())
{
quiz1 = grades.next();
quiz2 = grades.next();
midterm = grades.next();
final = grades.next();

if(quiz1 > 10 )
System.out.println("ERROR quiz 1");
if(quiz2 > 10 )
System.out.println("ERROR quiz 2");
if(midterm > 100 )
System.out.println("ERROR midterm");
if(final > 100)
System.out.println("ERROR final");


average = ( (midterm / 100) * .25 ) + ( ( quiz1/10 ) * .125 ) + ( ( quiz2/10 ) * .125 ) + ( ( final/100 ) * .50);


System.out.println(" Quiz 1 score = " + quiz1 );

}
Dec 7 '06 #1
Share this Question
Share on Google+
4 Replies


10K+
P: 13,264
i am trying to created a program that will write a grading program for a class with the following policies

there are 2 quizzes each graded on the basis of 10 points
there is 1 midterm and 1 final each graded on 100 points
the final exam counts for 50% of the grade, the midterm counts for 25% and the 2 quizzes togehter count for a total of 25%(i have to normailze the scores)

letter grades based on
90-100 A
80-89 B
70-79 C
60-69 D
0-59 E
the program will read in the student's scores from a text file, and output the students record which will have the names 2 quiz, and 2 exam as well as the student's average numeric score for the enitre course.(all scores are intergers )
i want to use standard I/O
the following is the code i have come up with
Class grade{
public static void main(String[] args){

double quiz1, quiz2, midterm, final, average;

Scanner grades = new Scanner(System.in);

while(grades.hasNext())
{
quiz1 = grades.next();
quiz2 = grades.next();
midterm = grades.next();
final = grades.next();

if(quiz1 > 10 )
System.out.println("ERROR quiz 1");
if(quiz2 > 10 )
System.out.println("ERROR quiz 2");
if(midterm > 100 )
System.out.println("ERROR midterm");
if(final > 100)
System.out.println("ERROR final");


average = ( (midterm / 100) * .25 ) + ( ( quiz1/10 ) * .125 ) + ( ( quiz2/10 ) * .125 ) + ( ( final/100 ) * .50);


System.out.println(" Quiz 1 score = " + quiz1 );

}


Expand|Select|Wrap|Line Numbers
  1.  
  2. import java.util.*; //For the scanner
  3. import java.io.*; //For the io classes
  4. class grade{ //java is case sensitive class not Class
  5. public static void main(String[] args){
  6. double quiz1, quiz2, midterm, finalMark, average; //final is a key word. Do not use it as an identifier
  7. Scanner grades = new Scanner(System.in); 
  8. //You need to use the FileReader class to read from the file
  9. while(grades.hasNext()) {
  10.  quiz1 = grades.nextDouble();
  11.  quiz2 = grades.nextDouble();
  12.  midterm = grades.nextDouble();
  13.  finalMark = grades.nextDouble();
  14.  if(quiz1 > 10 )
  15.   System.out.println("ERROR quiz 1");
  16.  if(quiz2 > 10 )
  17.   System.out.println("ERROR quiz 2");
  18.  if(midterm > 100 )
  19.   System.out.println("ERROR midterm");
  20.  if(finalMark > 100)
  21.   System.out.println("ERROR final");
  22.  
  23.  average = ( (midterm / 100) * .25 ) + ( ( quiz1/10 ) * .125 ) + ( ( quiz2/10 ) * .125 ) + ( ( finalMark/100 ) * .50);
  24.  
  25.  System.out.println(" Quiz 1 score = " + quiz1 );
  26. }
  27. }
  28.  
  29.  
Read about how to read a file and correct your code then post and we'll see how far you will have got
Dec 7 '06 #2

P: 14
hjc
thanks for the help-i am not understanding your question could you re word it
Dec 7 '06 #3

10K+
P: 13,264
thanks for the help-i am not understanding your question could you re word it
Did you read the comments in the code? I did not really ask a question but I asked you to read a tutorial on how to read files, re-write your code and post it then we work from there.
Dec 7 '06 #4

P: 14
hjc
thanks i will and i will
Dec 7 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.