Search code examples
javabluej

A compiling Error I cannot figure out in BlueJ


I am getting the ')' expected error when I try to compile on one of my print f statements. The project is to write an application that will run on cash registers in a pizza restaurant. Here is the section of code. The problem line is the one inside the double asterisks. Any ideas?

System.out.println();
System.out.println ("       Order Summary ");
System.out.println (" *************************");
System.out.println ();

if(NofTopp = 0){
    System.out.printf( Size + ", " + crust + " Cheese Pizza : $%.2f", cost);
    System.out.println();
}else if(NofTopp = 1){
    System.out.printf( Size + ", " + crust + " Pizza with " + Top1 + ": $%.2f", cost);
    System.out.println();
}else if(NofTopp = 2){
    **System.out.printf (Size + ", " + crust + " Pizza with " + Top1 + " and " + Top2 ": $%.2f", 
 cost);**
    System.out.println();
}else if(NofTopp = 3){
    System.out.printf( Size + ", " + crust + " Pizza with " + Top1 + ", " + Top2 + " and " + Top3 + 
": $%.2f", cost);
    System.out.println();
}

System.out.printf ("Tax: $%.2f",SalesTax );
System.out.println();

System.out.printf ("Total: $%.2f",totalCost );
System.out.println();

Solution

  • I think you forgot a + before the ": $%.2f". Try:

    System.out.printf (Size + ", " + crust + " Pizza with " + Top1 + " and " + Top2 + ": $%.2f", cost);