Follow Us
Contribute
  • Register
Errorbase is a collaborative writing project, that aims to build the largest trouble-shooting guide about all kinds of error messages.

Categories

0 votes

Exception in thread "main" java.util.InputMismatchException

     at java.util.Scanner.throwFor(Unknown Source)

     at java.util.Scanner.next(Unknown Source)

     at java.util.Scanner.nextDouble(Unknown Source)

     at Ch3_PrExercise7.main(Ch3_PrExercise7.java:33)

 

 

import java.io.*;
import java.util.*;
 
public class Ch3_PrExercise7
{
public static void main(String[] args) 
throws FileNotFoundException
{
Scanner inFile = new Scanner(new FileReader("Ch3_Ex7Data.txt")); PrintWriter outFile = new PrintWriter("Ch3_Ex7Output.dat");
  
double salary1, salary2, salary3;
double percent1, percent2, percent3;
double updatedSalary1, updatedSalary2, updatedSalary3;
 
String firstName1, firstName2, firstName3;
String lastName1, lastName2, lastName3;
 
lastName1 = inFile.next();
firstName1 = inFile.next();
lastName2 = inFile.next();
firstName2 = inFile.next();
lastName3 = inFile.next();
firstName3 = inFile.next();
 
salary1 = inFile.nextDouble();
salary2 = inFile.nextDouble();
salary3 = inFile.nextDouble();
percent1 = inFile.nextDouble();
percent2 = inFile.nextDouble();
percent3 = inFile.nextDouble();
 
updatedSalary1 = (salary1 + (salary1 * percent1 / 100));
updatedSalary2 = (salary2 + (salary2 * percent2 / 100));
updatedSalary3 = (salary3 + (salary3 * percent3 / 100));
 
outFile.printf(firstName1 + " " + lastName1 + " " 
+ "%$5.2f %n", updatedSalary1 + "\n"
+ firstName2 + " " + lastName2 + " "
+ "%$5.2f %n", updatedSalary2 + "\n"
+ firstName3 + " " + lastName3 + " "
+ "%$5.2f %n", updatedSalary3);
 
inFile.close();
outFile.close(); 
}
}
requested by
edited
share the code of Ch3_PrExercise7 please...

Please log in or register to to add a solution for this error.

...