This is my program and I am not getting the right output, it shows I do not have errors in the program what when I run it, it asks for the right information but it does not give the right results. This is what comes up in my output
run:
Enter Name and annual sales of first salesman: Rick, 92,000
Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Num berFormatException.java:65) this is line 65, /**
at java.lang.Integer.parseInt(Integer.java:504) this is line 504, throw NumberFormatException.forInputString(s);
at java.lang.Integer.parseInt(Integer.java:527) this is line 527, return parseInt(s,10);
at sales.commission.week.pkg4.SalesCommissionWeek4.ma in(SalesCommissionWeek4.java:73) this is line 73, /**
Java Result: 1
BUILD SUCCESSFUL (total time: 47 seconds)
This is my program
Can someone help me please, I am confused./* * To change this template, choose Tools | Templates * and open the template in the editor. */ package sales.commission.week.pkg4; import java.io.IOException; import java.util.Scanner; /** * * @author reco */ public class SalesCommissionWeek4 { Calculator obj1; Calculator obj2; float deficit; /*CommissionCalculator()*/{ obj1 = new Calculator(); obj2 = new Calculator(); } public void setAttributes(int i, String s, int j, String l){ obj1.setName(s); obj1.setAnnualSales(i); obj2.setName(l); obj2.setAnnualSales(j); } public void compare() { if(obj1.getTotalCompensation()<obj2.getTotalCompensation()){ deficit = obj2.getTotalCompensation()-obj1.getTotalCompensation(); if(obj1.getAnnualSales()<=120000){ System.out.print(obj1.getName()+" should increase his annual sales by " + obj2.getCommission()/0.05); } if(obj1.getAnnualSales()>120000) { System.out.print(obj1.getName()+" should increase his annual sales by " + obj2.getCommission()/0.065); } } else if(obj2.getTotalCompensation()<obj1.getTotalCompensation()){ deficit = obj1.getTotalCompensation()-obj2.getTotalCompensation(); if(obj2.getAnnualSales()<=120000) { System.out.print(obj2.getName()+" should increase his annual sales by " + obj1.getCommission()/0.05); } if(obj2.getAnnualSales()>=120000) { System.out.print(obj2.getName()+" should increase his annual sales by " + obj1.getCommission()/0.065); } } else{ System.out.print("Compensations are equal."); System.exit(0); } } public static void main(String[] args) throws IOException { Scanner read = new Scanner(System.in); String t1,t2; int i=0,j=0; Calculator obj = new Calculator(); System.out.print("Enter Name and annual sales of first salesman: "); t1 = read.nextLine(); String temp1 = read.nextLine(); i=Integer.parseInt(temp1); System.out.print("Enter Name and annual sales of second salesman: "); t2 = read.nextLine(); String temp2 = read.nextLine(); j=Integer.parseInt(temp2); obj.setAttributes(i, t1, j, t2); obj.compare(); } } /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package sales.commission.week.pkg4; /** * * @author reco */ final class Calculator { private int income; private int annualSales; private float commission; private float totalCompensation; private String name; Calculator //</editor-fold> () { annualSales=0; income=40000; commission=0; totalCompensation=0; } Calculator(int i, String s) { annualSales=i; income=40000; commission=0; totalCompensation=0; name=s; calcCommission(); } public void setAnnualSales(int i){ annualSales=i; calcCommission(); } public void setName(String s){ name=s; } public void calcCommission() { if(annualSales < 100000){ totalCompensation = income; } else if(annualSales >= 100000 && annualSales <= 120000){ commission = (float) (0.05 * annualSales); totalCompensation = commission+income; } else{ commission = (float) (0.080 * annualSales); totalCompensation = commission+income; } } public float getTotalCompensation(){ return totalCompensation; } public int getAnnualSales(){ return annualSales; } public float getCommission() { return commission; } public String getName(){ return name; } public void printTable() { float temp = annualSales; while(temp <= annualSales*1.5) { if(temp < 100000){ totalCompensation = income; System.out.println("Total Compensation at sales "+temp+" is: "+totalCompensation); } else if(temp >= 100000 && temp <= 120000){ commission = (float) (0.05 * annualSales); totalCompensation = commission+income; System.out.println("Total Compensation at sales "+temp+" is: "+totalCompensation); } else{ commission = (float) (0.080 * annualSales); totalCompensation = commission+income; System.out.println("Total Compensation at sales "+temp+" is: "+totalCompensation); } temp += 5000; } } void setAttributes(int i, String t1, int j, String t2) { throw new UnsupportedOperationException("Not yet implemented"); } void compare() { throw new UnsupportedOperationException("Not yet implemented"); } }