Errors with simple program... PLEASE HELP ME!!!
I am supposed to be writing this program and this is what I have so far...
import java.io.*;
import java.util.*;
public class assignment
{
public static void main(String[] args) throws FileNotFoundException
{
double quiz1, quiz2, quiz3, quiz4;
double average;
String firstName;
String lastName;
Scanner inFile =
new Scanner(system.n);
PrintWriter outFile = new
PrintWriter("testavg.out");
firstName = inFile.next();
lastName = inFile.next();
outFile.println("Student Name: "
+ firstName + " " + lastName);
quiz1 = inFile.nextDouble();
quiz2 = inFile.nextDouble();
quiz3 = inFile.nextDouble();
quiz4 = inFile.nextDouble();
average = (quiz1 + quiz2 + quiz3 + quiz4) / 4.0;
outFile.printf("Average quiz score: %5.2f %n",
average);
if (average>=90)System.out.println("A");
else if (average>=80)System.out.print("B");
else if (average>=70)System.out.print("C");
else if (average>=60)System.out.print("D");
else if (average<=50)System.out.print("F");
inFile.close();
outFile.close();
}
}
WHAT I NEED TO DO IS WRITE IT SO THAT THE USER INPUTS A NUMBER OF QUIZES AND IT FINDS THE AVERAGE. AND I CAN NOT FIX THE ERRORS. IE. THE SCANNER ERROR
PLEASE HELP ME!!!!
Alright so I tried this... but
Alright so I tried what you said and no way I can think of does it work... if you would not mind helping me...
.....
int Scnanner (System.in) intArray = new int[];
//Step 6 - retrieve the five test scores
quiz1 = inFile.nextDouble();
quiz2 = inFile.nextDouble();
quiz3 = inFile.nextDouble();
quiz4 = inFile.nextDouble();
outFile.printf("Quiz scores: %5.2f %5.2f %5.2f "
+ "%5.2f %n", quiz1, quiz2,
quiz3, quiz4);
average = (quiz1 + quiz2 + quiz3 + quiz4) / new int[]; //Step 8
outFile.printf("Average quiz score: %5.2f %n",
average);
if (average>=90)System.out.println("A");
.....
Here are the errors:
/export/home/students/jgiannin/exampleStudentGrade.java:30: ';' expected
int Scnanner System.in intArray = new int[];
^
/export/home/students/jgiannin/exampleStudentGrade.java:42: array dimension missing
average = (quiz1 + quiz2 + quiz3 + quiz4) / new int[];
^
2 errors
----jGRASP wedge: exit code for process is 1.
----jGRASP: operation complete.