Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Fix my code package employeeInfo; import java.io . * ; import java.util.Scanner; public class Employee { public static void main ( String [ ] args
Fix my code package employeeInfo; import java.io . * ; import java.util.Scanner; public class Employee { public static void main ( String [ ] args ) throws FileNotFoundException { / / Try block to check for exceptions try ( Scanner inFile = new Scanner ( new File ( " employee _ data.txt " ) ) ) { inFile.useDelimiter ( " " ) ; double idNumber, hourlyRate, hoursWorked, grossPay; String employeeName; System.out.printf ( " % - 15 s % - 15 s % s " , "Employee","ID# " , "Gross Pay" ) ; System.out.printf ( " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " ) ; while ( inFile . hasNext ( ) ) { employeeName = inFile.next ( ) ; idNumber = Double.parseDouble ( inFile . next ( ) ) ; hourlyRate = Double.parseDouble ( inFile . next ( ) ) ; hoursWorked = Double.parseDouble ( inFile . next ( ) ) ; grossPay = hourlyRate * hoursWorked; System.out.printf ( " % - 15 s % - 15 s$ % . 2 f " , employeeName, idNumber, grossPay ) ; } } } } Exception in thread "main" java.lang.NumberFormatException: For input string: " # 824 " at java.base / jdk . internal.math.FloatingDecimal.readJavaFormatString ( FloatingDecimal . java: 2054 ) at java.base / jdk . internal.math.FloatingDecimal.parseDouble ( FloatingDecimal . java: 110 ) at java.base / java . lang.Double.parseDouble ( Double . java: 651 ) at Employee / employeeInfo . Employee.main ( Employee . java: 26 )
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started