fork download
  1. import java.util.Scanner;
  2.  
  3. class ChiliToGo
  4. {
  5. public static void main (String[] args)
  6. {
  7. final int PRICE_FOR_ADULT = 7;
  8. final int PRICE_FOR_CHILD = 4;
  9.  
  10. int adultMeals;
  11. int childMeals;
  12.  
  13. Scanner scanner = new Scanner(System.in);
  14.  
  15. System.out.print("Input the number of adult meals:");
  16. adultMeals = scanner.nextInt();
  17.  
  18. System.out.println("Input the number of child meals:");
  19. childMeals = scanner.nextInt();
  20.  
  21. int totalPriceAdult = adultMeals * PRICE_FOR_ADULT;
  22. int totalPriceChild = childMeals * PRICE_FOR_CHILD;
  23. int totalProfit = totalPriceAdult + totalPriceChild;
  24.  
  25. System.out.println("There are " + adultMeals + " adult meal(s).");
  26. System.out.println("There are " + childMeals + " child meal(s).");
  27. System.out.println("The total price of the meals is $" + totalProfit);
  28. }
  29. }
Success #stdin #stdout 0.14s 58824KB
stdin
2
2
stdout
Input the number of adult meals:Input the number of child meals:
There are 2 adult meal(s).
There are 2 child meal(s).
The total price of the meals is $22