Question

JAVA Habitat for Humanity hosted a one-day fund raiser to assist local families. The charity sold...

JAVA

Habitat for Humanity hosted a one-day fund raiser to assist local families. The charity sold chicken dinners. The price of an adult meal was $10.00. The price of a child's meal was $5.00. Write a program that accepts the total number of meals sold for both groups. Display the total meals sold for the adult meals and the total meals sold for the children's meals. Display the total meals sold for all groups. Save the program as instructed. See the sample program below.

Step 1:

Ask the user for the number of adult meals.

Step 2:

Ask the user for the number of children's meals.

Step 3:

Calculate the price of the adult meals.

Step 4:

Calculate the price of the children's meals.

Step 5:

Display the price of the adult meals.

Step 6:

Display the price of the children's meals.

Step 7:

Display the price of all meals (adult meals plus the children's meals).

Step 8:

Your program should include appropriate comments. The first comment should be: This program was created by: Add your name here

Sample Input and Output (user input is in bold)

Do not modify the output. The output should display as shown below. Note: the input below is only an example of user input. Your program should be able to calculate whatever amount the user enters.

Enter the number of adult meals sold: 200
Enter the number of children's meals sold: 100


Adult Dinners: $2000.00
Children's Dinners: $500.00
Total Meals: $2500.00

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE IN JAVA:

MealCost.java file:

import java.util.Scanner;
public class MealsCost {

   public static void main(String[] args) {
       // creating object to the Scanner class to take input from the user
       Scanner sc = new Scanner(System.in);
       // asking number of adult meals sold
       System.out.print("Enter the number of adult meals sold : ");
       int adultMeals = sc.nextInt();
       //asking number of child meals sold
       System.out.print("Enter the number of child meals sold : ");
       int childMeals = sc.nextInt();
       // defining meals cost
       double adultMealCost = 10.0 ;
       double childMealCost = 5.0;
       //calculating total cost
       double totalAdultMealCost = adultMeals * adultMealCost ;
       double totalChildMealCost = childMeals * childMealCost ;
       double totalCost = totalAdultMealCost + totalChildMealCost ;
       System.out.println("Adult dinners : $" + totalAdultMealCost);
       //displaying the result
       System.out.println("Children's dinners : $" + totalChildMealCost);
       System.out.println("Total Meals : $" + totalCost);

   }

}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
JAVA Habitat for Humanity hosted a one-day fund raiser to assist local families. The charity sold...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A cruise ship offers the following packages for 5 day / 4 night Cruise & Stay....

    A cruise ship offers the following packages for 5 day / 4 night Cruise & Stay. Package 1. Room only Rate $1000.00 $1000.00 $200.00 for each person sharing the room (Maximum 3) 2. Room plus Meals Discount Details (just for package 2): -$50.00: if just one of the occupant is 17 or under $80.00: if at least two of the occupants are 17 or under Write a program to ask the user the following information The package type (R: Room...

  • Write a program that computes and displays a customer’s bill for an All-You-Can-Eat Buffet Restaurant. The...

    Write a program that computes and displays a customer’s bill for an All-You-Can-Eat Buffet Restaurant. The charge for an adult meal is $6.00 and a child’s (ages 5 to 10) meal is $3.00. The tax rate is 6.5%. The desserts offered at the restaurant are slices of pie at $1.00 per slice. Gratuity is automatically calculated at 15%. Use main( ) as the driver function. Allow the user to process as many customer bills as desired. Use named constants and...

  • Write a Java Program that performs the following functionalities: and you can use if statements, cases,...

    Write a Java Program that performs the following functionalities: and you can use if statements, cases, and string methods Enter a new main sentence Find a String Find all incidents of a String Find and Replace a String Replace all the incidents of a String Count the number of words Count a letter’s occurrences Count the total number of letters Delete all the occurrences of a word Exit The program will display a menu with each option above, and then...

  • Write a Java program that calculates how much a person would earn after a period of...

    Write a Java program that calculates how much a person would earn after a period of time, according to the following rules: 1. The starting salary for the first day is $1. 2. The salary will double each day. Ask the user to input the number of days worked. The output should display how much the salary was for each day worked, and show the total pay at the end of the work period. Get output similar to the sample...

  • Help. In language c View Layout References Mailings Program 1 Write a simple invoice generating program...

    Help. In language c View Layout References Mailings Program 1 Write a simple invoice generating program for a pet store as follows: 1- Ask the user for tee tax rate and store it in a float variable. 2- Ask the user for the number of cats being purchased and store the value in an integer variable. 3- Ask the user for the price of one cat and store it in a float variable. 4- Ask the user for the number...

  • by java langage QI A small online grocery store sells fruits with the following prices: Apple,...

    by java langage QI A small online grocery store sells fruits with the following prices: Apple, 1.500 KWD; Orange, 0.700 KWD; Banana, 1.000 KWD; Peach, 2.500 KWD; and Melon, 1.750 KWD. Write an application that reads a series of pairs of values as follows: 1. fruit name 2. quantity sold Your program should use a switch statement to determine the price for each fruit. It should then calculate and display the total retail value of all sold fruits (e.g., if...

  • C++; functions declared in main, but defined out side of main You've just feasted on a...

    C++; functions declared in main, but defined out side of main You've just feasted on a truly delicious meal of spam and eggs and a couple of pints of Davey Jones’s ale. Unfortunately, you are on board a pirate ship so payment is a little tricky. You need to calculate not only the cost of your meal, but also the governor’s tax, the captain’s tax, and a tip for the ship mates serving you as well as a sundry of...

  • Java I: Create a Java program that will accept the price of an item and the...

    Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...

  • Write a program for a Buffet to display the bill Sor the cashicr The buffet serves a chef's meu with two options 31 50 The total adu bill is roduced by $5.00 if there are 9 aor more ad $15....

    Write a program for a Buffet to display the bill Sor the cashicr The buffet serves a chef's meu with two options 31 50 The total adu bill is roduced by $5.00 if there are 9 aor more ad $15.00 It is free after the third child maximum of 3 childrm) The program requests the name and zip code ofthe buf1ส and converts the tru The pr- then aceepts the number of adults and children, performs the necessary calculations compues...

  • What would the flowchart look like for this? Best Friends Dog Rescue is hosting a Movie...

    What would the flowchart look like for this? Best Friends Dog Rescue is hosting a Movie Charity Event and needs your help capturing what percentage of the night’s sales will be donated to their rescue group. The program should calculate total cost for the number of movie tickets sold for Adults and Children, as well as Snack Sales. The total combined sales for movie ticket sales and snacks should be calculated; and then the percentage of that total calculated. You...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT