Originally posted by Voltage Spike
Man, i'm so awesome.
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
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();
Leave a comment: