Good evening forum dwellers! I've been working on a small Java problem in my spare time and have come to a stand-still within a couple of minutes! Ugh. My code:
My compiling errors:
Any constructive responses are welcomed and appreciated. Please keep in mind that I am just starting Java and am merely dipping my toes in. Thanks!
Code:
import java.io.*; import java.util.*; import java.text.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class pgm02bhc { public static void main ( String[] args ) throws IOException { // initialize keyboard input BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); // initialize variables char payCode; String empName; float commBase = 250f, commPCT = 0.057f, stdHrs = 40; float piecesCompleted, amount, salaryPay, totalSales, hrlyRate, hrsWorked, total; // initialize report file PrintWriter outFile = new PrintWriter(new FileWriter ( "pgm02bhc.rpt" )); // insert statements here headings ( outFile ); getEmpName ( keyboard, empName ); // garbage collection and return to zero System.gc (); System.exit(0); // close report file outFile.close(); } // end main // **************************************************methods******************************************** public static void headings ( PrintWriter outFile ) { outFile.println("Employee Name \t Pay Code \t Total Pay"); outFile.println(); } public static String getEmpName ( BufferedReader keyboard, String empName ) { System.out.print( "Please enter employee name (enter to quit): " ); empName = keyboard.readLine(); return empName; } } // end public class pgm02bhc
Code:
pgm02bhc.java:37: variable empName might not have been initialized getEmpName ( keyboard, empName ); ^ pgm02bhc.java:56: unreported exception java.io.IOException; must be caught or declared to be thrown empName = keyboard.readLine();
Comment