Java program grading

Posted by pasito15 on Stack Overflow See other posts from Stack Overflow or by pasito15
Published on 2012-07-03T21:13:01Z Indexed on 2012/07/03 21:15 UTC
Read the original article Hit count: 217

Filed under:
|

I've been working on this program for hours and I can't figure out how to get the program to actually print the grades from the scores Text file

public class Assign7{
  private double finalScore;
  private double private_quiz1;
  private double private_quiz2;
  private double private_midTerm;
  private double private_final;
  private final char grade;


  public Assign7(double finalScore){
    private_quiz1 = 1.25;
    private_quiz2 = 1.25;
    private_midTerm = 0.25;
    private_final = 0.50;

       if (finalScore >= 90) {
           grade = 'A';
       } else if (finalScore >= 80) {
           grade = 'B';
       } else if (finalScore >= 70) {
           grade = 'C';
       } else if (finalScore>= 60) {
           grade = 'D';
       } else {
           grade = 'F';
       }
}


  public String toString(){
    return finalScore+":"+private_quiz1+":"+private_quiz2+":"+private_midTerm+":"+private_final;

  }
} 

this code compiles as well as this one

import java.util.*;
import java.io.*;

public class Assign7Test{
  public static void main(String[] args)throws Exception{

  int q1,q2;
  int m = 0;
  int f = 0;
  int Record ; 
  String name;





    Scanner myIn = new Scanner( new File("scores.txt") );



    System.out.println( myIn.nextLine() +"  avg  "+"letter");

   while( myIn.hasNext() ){
      name = myIn.next();
      q1 = myIn.nextInt();
      q2 = myIn.nextInt();
      m = myIn.nextInt();
      f = myIn.nextInt();
       Record myR = new Record( name, q1,q2,m,f);
       System.out.println(myR);

      }
    }


public static class Record {

       public Record() {
       }

       public Record(String name, int q1, int q2, int m, int f)
       { 

       } 
   } 
}

once a compile the code i get this which dosent exactly compute the numbers I have in the scores.txt Name quiz1 quiz2 midterm final avg letter

Assign7Test$Record@4bcc946b

Assign7Test$Record@642423

Exception in thread "main" java.until.InputMismatchException

at java.until.Scanner.throwFor(Unknown Source)

at java.until.Scanner.next(Unknown Source)

at java.until.Scanner.nextInt(Unknown Source)


at java.until.Scanner.nextInt(Unknown Source)

at Assign7Test.main(Assign7Test.java:25)

© Stack Overflow or respective owner

Related posts about java

Related posts about homework