error: variable might not have been initialized

  May 21, 2017

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;
2. error: variable am might not have been initialized
tcws= cm+tm+ac+am+ta;
3. error: variable ta might not have been initialized
tcws= cm+tm+ac+am+ta;

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); } } }

In Progress 0
java;error;variable 3 months ago 0 Answer 0 views

Answers ( 0 )

Your Answer