151k views
5 votes
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 ChilisToGo.java.

2 Answers

5 votes

Here's a Java program named ChilisToGo.java that calculates the total money collected for adult meals, children’s meals, and all meals based on the number of each meal ordered:

The Java Program

import java.util.Scanner;

public class ChilisToGo {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

// Accept the number of adult and child meals ordered

System.out.print("Enter the number of adult meals ordered: ");

int adultMeals = input.nextInt();

System.out.print("Enter the number of child's meals ordered: ");

int childMeals = input.nextInt();

// Calculate the total money collected for adult meals, children’s meals, and all meals

double adultTotal = adultMeals * 7;

double childTotal = childMeals * 4;

double totalCollected = adultTotal + childTotal;

// Display the total money collected for each type of meal and overall

System.out.println("Total money collected for adult meals: $" + adultTotal);

System.out.println("Total money collected for children's meals: $" + childTotal);

System.out.println("Total money collected for all meals: $" + totalCollected);

input.close();

}

}

This program prompts the user to enter the number of adult meals and children's meals ordered, calculates the total money collected for each meal type and overall, and displays the results accordingly.

User Thunderblaster
by
4.7k points
4 votes

Answer:

Hi Um how do i create an answer/question on here? I have a question about aa qestion on my quiz

Step-by-step explanation:

User Nikhil Maheshwari
by
4.7k points