//Tip based on service package mealcost; import java.util.*; public class CalculateTip { public static void main(String[] args) { Scanner keyboard=new Scanner(System.in); //do just once double cost, tip; String service; System.out.print("Enter the cost of the meal: $"); cost=keyboard.nextDouble(); System.out.print("Was the service good (Y or N):"); service=keyboard.next(); switch(service) { case "Y": case "y": tip=cost*0.20; break;//20% for good service case "N": case "n": tip=cost*0.15; break;//15% for ok service default: System.out.println("not a valid answer"); tip=0.00; } System.out.println(String.format("The tip should be $%.2f",tip)); }//main }//class