Results 1 to 2 of 2
Thread: Help!!! Please!!
- 03-10-2011, 09:19 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 1
- Rep Power
- 0
Help!!! Please!!
So this is what I have so far... and I need it to get the input from a .txt file that contains (Sales Program Data
KM2506 1097.52 798.52
SL1561 745.10 700.10
RT8109 568.19 520.19
WQ4178 772.00 689.00
PL8979 2590.65 2140.50)
and I need it to display

the command prompt keeps saying
Exception in thread "main" java.lang.NumberFormatException: For input string: "KM2506"
at sun.misc.FloatingDecimal.readJavaFormatString(Floa tingDecimal.java:1224)
at java.lang.Double.parseDouble(Double.java:510)
at Table.main(Table.java:51)
please help!! Thank you!
my program so far:
import java.util.*;
public class Table1{
public static void main(String[] args){
tale();
heading();
tale();
Scanner keyboard = new Scanner(System.in);
String firstline;
String col1;
String col2;
String col3;
double idnumber;
double totalsales;
double netsales;
double profit;
double commission;
while (keyboard.hasNextLine()){
firstline = keyboard.nextLine();
col1 = keyboard.next();
col2 = keyboard.next();
col3 = keyboard.next();
idnumber = Double.parseDouble(col1);
totalsales = Double.parseDouble(col2);
netsales = Double.parseDouble(col3);
profit = totalsales - netsales;
commission = .13 * profit;
System.out.println(idnumber);
System.out.printf("%12.2f", totalsales);
System.out.printf("%12.2f", netsales);
System.out.printf("%12.2f", profit);
System.out.printf("%12.2f", commission);
}
}
public static void heading(){
System.out.printf("ID TOTAL NET PROFIT COMMISSION%n");
System.out.printf("NUMBER SALES(A) SALES(B) (A - B) 13*(A - B)%n");
}
public static void tale(){
System.out.printf("-----------------------------------------------------------%n");
}
}
[/SIZE]
- 03-10-2011, 09:41 PM #2


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks