The Huntington Boys and Girls Club is conducting a fundraiser by selling chili dinners to go. The price is $7 for an adult meal and $4 for a child’s meal. Write a program that accepts the number of each type of meal ordered and display the total money collected for adult meals, children’s meals, and all meals. Save the program as ChiliToGo.java.
Must be using JOption.
Thanks!
For the above program, we need to have the following things into consideration.
Following is the code in java.
import java.util.Scanner;
public class ChillToGo {
public static void main(String args[]) {
Scanner scan = new
Scanner(System.in);
System.out.print("Adult's Meals:
");
int adult_meals =
scan.nextInt();
System.out.print("Child's Meals:
");
int child_meals =
scan.nextInt();
int adult_meals_cost =
adult_meals*7;
int child_meals_cost =
child_meals*4;
System.out.println("Cost of Adult
Meals: " + adult_meals_cost);
System.out.println("Cost of Child
Meals: " + child_meals_cost);
System.out.println("Total Cost: " +
(adult_meals_cost + child_meals_cost));
}
}
Following is the snippet of the program output.
That was a nice
question to answer
Friend, If you have any doubts in understanding do let me know in
the comment section. I will be happy to help you further.
Please like if you think effort deserves like.
Thanks
Get Answers For Free
Most questions answered within 1 hours.