Question

In: Computer Science

B. Creation of Program Application (Development Task 1) This program should ask the following questions to...

B. Creation of Program Application (Development Task 1) This program should ask the following questions to determine the number of hotdogs and buns (with minimum number of leftovers) needed for the Annual Hotdog Eating contest:

Assumptions are as follows:

• Hotdogs come in packages of 10.

• Hotdog buns come in packages of 8.

1. The program application should have the following inputs:

• How many people will be competing in the contest?

• How many hotdogs will each person be able to eat?

2. The program application should have the following outputs:

• The minimum number of packages of hotdogs required.

• The minimum number of packages of hotdog buns required.

• The number of hotdogs that will be left over.

• The number of hotdog bunds that will be left over.

3.) Must handle keyboard buffering properly.

4.) Must display proper data formatting of arguments.

5.) Mathematical calculations must be correct

I am writing this in Java

Solutions

Expert Solution

Short Summary:

  • Implemented a console application using java.
  • Provided inline comments appropriately
  • Shown you various output with different input values

**************Please upvote the answer and appreciate our time.************

Source Code:

import java.util.Scanner;

public class HotDogsBuns {
   private static int HOTDOG_COUNT_PKG = 10;
   private static int BUNS_COUNT_PKG = 8;
  
   public static void main(String[] args) {
       //Scanner object to get user input
       Scanner keyboard = new Scanner(System.in);
      
       // Get number of people
       System.out.print("How many people will be competing in the contest?: ");
       int noOfPeople = keyboard.nextInt();
       keyboard.nextLine();
      
       // Get number of hotdogs per person
       System.out.print("How many hotdogs will each person be able to eat?: ");
       int countPerPerson = keyboard.nextInt();
       keyboard.nextLine();
      
       // Total HotDogs required
       int totalRequired = noOfPeople * countPerPerson;
      
       //The minimum number of packages of hotdogs required.
       int noOfHotDogPkgs = totalRequired / HOTDOG_COUNT_PKG;
       if (totalRequired % HOTDOG_COUNT_PKG != 0) {
           noOfHotDogPkgs++;
       }
       System.out.println("The minimum number of packages of hotdogs required: " + noOfHotDogPkgs);
      
       //The minimum number of packages of hotdog buns required.
       int noOfBunPkgs = totalRequired / BUNS_COUNT_PKG;
       if (totalRequired % BUNS_COUNT_PKG != 0) {
           noOfBunPkgs++;
       }
       System.out.println("The minimum number of packages of hotdog buns required: " + noOfBunPkgs);
      
       //The number of hotdogs that will be left over
       int leftOverHotDogs = (noOfHotDogPkgs * HOTDOG_COUNT_PKG) - totalRequired;
       System.out.println("The number of hotdogs that will be left over: " + leftOverHotDogs);
      
       //The number of hotdog buns that will be left over.
       int leftOverBuns = (noOfBunPkgs * BUNS_COUNT_PKG) - totalRequired;
       System.out.println("The number of hotdog buns that will be left over: " + leftOverBuns);
      
       //close the scanner
       keyboard.close();
      
   }

}

Refer the following screenshots for code indentation:

Sample Run 1:

Sample Run 2:

**************************************************************************************

Feel free to rate the answer and comment your questions, if you have any.

Please upvote the answer and appreciate our time.

Happy Studying!!!

**************************************************************************************


Related Solutions

Creation of Program Application (Development Task 1) This program should create two output files. You may...
Creation of Program Application (Development Task 1) This program should create two output files. You may use .txt files. Create the following files: Deposists.txt Withdrawls.txt 1. The program application should have the following inputs: Amount for Deposits (Only Accept Positive Amounts) Amount for Withdrawals (Only Accept Positive Amounts). The subsequent program will subtract the positive amount. 2. The program application should have the following outputs: Deposists.txt Withdrawals.txt Total of Deposits and Withdrawals back to the console
I am using Java and what do you mean samples? Creation of Program Application (Development Task...
I am using Java and what do you mean samples? Creation of Program Application (Development Task 2) This program should use a class file you create called: SavingsAccount. This class file should store the following information: Annual Interest Rate (this can be hardcoded) Starting Balance (use a constructor to accept this information) Create method to add all Deposits from Deposits.txt file. Create method to subtract all Withdrawals from Withdrawals.txt file. Create method to calculate the interest rate which is the...
In C: Write a complete program that performs the following task: Ask the user for the...
In C: Write a complete program that performs the following task: Ask the user for the number of sequences to display. For each sequence, Ask the user for a starting value Print out the value and double it (multiply by 2). Continue printing and doubling (all on the same line, separated by one space each) as long as the current number is less than 1000, or until 8 numbers have been printed on the line. You may assume that the...
Task 1. creating a nested if:   Need a python program that ask the user to enter...
Task 1. creating a nested if:   Need a python program that ask the user to enter the annual income of an employee and the years of experience. Pass these data to a function. The function decides if an employee does qualify for a loan or does not, then it prints a message based on the following rules: If the income is equal or greater than $40000, the function checks if the employee's years of experience is greater than 4, if...
Task 1: Some websites impose certain rules for passwords. Write a program that ask the user...
Task 1: Some websites impose certain rules for passwords. Write a program that ask the user to enter a password and checks whether a string (Use input validation to make sure the user enters the correct password and then print it.) is a valid password. Suppose the password rules are as follows: • A password must have list a least 10 characters. • A password must consist of only letters and digits. • A password must contain at least two...
Your Application should ask the user to enter their name and their salary.
Create a C# Console Application, name the solution Homework 6 and the project TaxRate.Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric...
Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
You will write a Java Application program to perform the task of generating a calendar for...
You will write a Java Application program to perform the task of generating a calendar for the year 2020. You are required to modularize your code, i.e. break your code into different modules for different tasks in the calendar and use method calls to execute the different modules in your program. Your required to use arrays, ArrayList, methods, classes, inheritance, control structures like "if else", switch, compound expressions, etc. where applicable in your program. Your program should be interactive and...
1 (a).In general, what types of questions should you not ask in an interview? Provide at...
1 (a).In general, what types of questions should you not ask in an interview? Provide at least two reasons why should you not ask them.     (b)Select and describe three Common Assessment Problems (forms of interview bias) that you feel are the most common.     (c) What is your opinion of using personality tests as a hiring tool?     (d) Do you feel that a Work Sample or Trial Shift are feasible testing tools that can be used for all...
write a python program to do the following: ask a student for 3 coefficients a b...
write a python program to do the following: ask a student for 3 coefficients a b c using the high_school_quizz to display the solutions of a quadratic problem. after, ask the student if he would like another quadratic equation solved If the student answers anything but yes, the program terminates by displaying a good bye message if the student answers yes (any form of yes should be acceptable) , the student is asked for the coefficient again and the resulting...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT