Results 1 to 2 of 2
  1. #1
    annalee0504 is offline Member
    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Default 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]

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,788
    Rep Power
    7

    Default

    Exception in thread "main" java.lang.NumberFormatException: For input string: "KM2506"
    Are you seriously telling us that you cannot tell that "KM2506" is not a valid number?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •