import java.util.Scanner;
import java.io.*;
public class GardinierPayrollP2
{
public static void main(String[] args) throws IOException
{
// int id; //i.d. number
// double hrsworkd; //hours worked
double wkspay = 0.00; //total amount before tax for an individual employee
double netpay = 0.00; //net pay to an individual after tax
double runningTotal = 0.00; //total amount of paid salaries
double runningNetTotal = 0.00; //net total after tax
double runningTaxTotal = 0.00; //total taxes payed
double levelA = 12.00;
double levelB = 14.50;
double levelC = 16.00;
double levelD = 20.00;
//String name; //employees First Name
//char level; //level of payment for employee
final double taxRate = .08; //tax rate @ 8%
double taxes = 0.00; //dollar amount of taxes payed
File employees = new File("employees.txt");
Scanner inputFile = new Scanner(employees);
while (inputFile.hasNext())
{
String name = inputFile.nextLine();
int id = inputFile.nextInt();
char level = inputFile.next().charAt(0);
double hrsworkd = inputFile.nextDouble();
System.out.println(name + id + level + hrsworkd);
}
}
}
This is what I'm working with. Second year of computer science. Not very versed in troubleshooting the errors yet. I know theres an input error. I just can't tell why. DrJava's output for it is to print the first four lines of the info and then throw the error. heres the output
> run GardinierPayrollP2
Rose Nylund901A10.0
java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at GardinierPayrollP2.main(GardinierPayrollP2.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:272)
>
Here's the input file
Rose Nylund
901
A
10.0
Dorothy Zbornak
534
D
11.5
Blanche Deveraux
109
B
5.0
Sophia Petrillo
729
C
2.5
What am I doing wrong?|