go to previous page   go to home page   go to next page hear noise highlighting

Answer:

The new improved program follows.


Programming Tips

Your program should look much like the following:

import java.util.Scanner;

public class RestaurantBill
{
  public static void main (String[] args)  
  {
    Scanner scan = new Scanner( System.in );
    double basicCost;
    double tipPercent;

    System.out.print("Enter the basic cost: ");
    basicCost = scan.nextDouble();
    System.out.print("Enter the tip percentage: ");
    tipPercent = scan.nextDouble();

    System.out.println("basic cost: " +  basicCost + " total cost: " + 
         (basicCost + basicCost*0.06 + basicCost*tipPercent) );
  }
}

QUESTION 11:

The println statement now uses the variable tipPercent, which contains the percentage the user wishes to tip.

If the println statement were not changed, would the Public Health Department give your program a passing grade?


go to previous page   go to home page   go to next page