Alright first off I think my JCreator isn't working right because I got it off of my school website for free. When I try to run the program I get a message about setting about a JDK path or something and that I need the newest version. I can right code in it but don't know if it will allow me to run it. Well back to the code.
What I got to do it create a program that reads from a file of baseball scores, name, at bats(ab) and hits. Then get the avg by ab/hits and output it to a file that the user names. The output file should be: Name Ab Hits Avg. Here's the code.
ERROR:
';' expected for lines 27,28,29....
What I got to do it create a program that reads from a file of baseball scores, name, at bats(ab) and hits. Then get the avg by ab/hits and output it to a file that the user names. The output file should be: Name Ab Hits Avg. Here's the code.
Code:
/**
* @(#)baseball.java
*
* baseball application
*
* @author
* @version 1.00 2011/2/5
*/
import java.util.Scanner;
import java.io.*;
class baseball {
public static void main(String[] args) {
String file = "C:\\Users\\Welcome Back\\Desktop";
input Scanner = new Scanner(new FileReader(file));
System.out.println("Enter the file to write to: ");
File outFile = new File(in.next());
String name;
int ab;
int hits;
float avg;
name = input Scanner.nextLine();
ab = input Scanner.nextLine();
hits = input Scanner.nextline();
avg = hits/ab;
System.out.printf(avg);
}
}
ERROR:
';' expected for lines 27,28,29....