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...
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...
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...
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...
[15] Create a program called StreamingWords.java that modifies the StreamingIntegers.java from Task 1. The program should...
[15] Create a program called StreamingWords.java that modifies the StreamingIntegers.java from Task 1. The program should be able to do the following: JAVA accepts user input. User inputs can be under the following forms: one or more words, separated by white space. User can provide multiple inputs (each input is completed after user hits Enter) To stop inputting data, user will enter END then hit Enter. reads inputs from users into a queue data structure. Each data element in the...
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...
Make a program that calculates the total of a retail sale. The program should ask the...
Make a program that calculates the total of a retail sale. The program should ask the user for the following: the retail price of the item being purchased and the sales tax rate. Once the information has been entered, the program should calculate and display the following: the sales tax for the purchase and the total sale.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT