//Tip based on service package mealcost; import java.util.*; public class CalcualteTip { 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(); tip=(service=="Y" || service=="y")? cost*0.20: cost*0.15; System.out.println(String.format("The tip should be $%.2f",tip)); }//main }//class