I am getting these 3 errors after compiling .. Pls help and thnx in advance..
- error: variable ac might not have been initialized tcws= cm+tm+ac+am+ta;
- error: variable am might not have been initialized tcws= cm+tm+ac+am+ta;
- error: variable ta might not have been initialized tcws= cm+tm+ac+am+ta;
My code:
import java.lang.*;
import java.util.Scanner;
class CellPhoneBill {
public static void main(String[]args) {
double cm ,tm ,ac, am, ta, tcws, tax, taxpluscost ;
Scanner s=new Scanner(System.in);
System.out.print("Enter the number of minutes and also enter the number of text messages ");
cm= s.nextDouble();
tm= s.nextDouble();
if(cm<=50&& tm<=50) {
System.out.print("Base charge= $15.00"); }
else if(cm>50 && tm>50) {
System.out.println("Enter no of additional call minutes (if any) and additional messages(if any) ");
ac=s.nextDouble();
am= s.nextDouble();
cm=0.25* ac;
am=0.15*am;
System.out.println("Additional call charges = " +ac);
System.out.println("Additional message charges = " +am);
ta=ac+am;
System.out.println("Total Additional charges = " +ta);
}
else if(cm>=0&& tm>=0) { System.out.println("911 Call charges =$0.44" );
}
else {
tcws= cm+tm+ac+am+ta;
System.out.println("Total cost without Sales Tax ="+tcws);
tax=( 5/100.00*(tcws));
System.out.println(" 5% Sales Tax ="+tax);
taxpluscost=tcws+tax;
System.out.println("Total cost Including 5% Sales Tax ="+taxpluscost);
}
}
}