Question

In: Computer Science

Answer this question on a new project. Use comments to explain how your program works, final...

Answer this question on a new project. Use comments to explain how your program works, final cpp to be uploaded just like you do the assignments.

A box of biscuit is able to hold 10 biscuits,
A container is capable of holding 25 boxes (equivalent to 250 biscuits), and
A truck is capable of moving 5 containers (equivalent to 1250 biscuits).

Write a C++ program that takes in an order of biscuits as input, determines and outputs the following; how many fully loaded trucks it will take to move the order, along with the spare containers, boxes and leftover biscuits you will have left. (DO NOT USE ANYTHING NOT YET COVERED IN CLASS. ALSO, FOR ACCURATE RESULTS, USE INTEGER VARIABLES FOR ENTIRE PROGRAM)

Example Results,

For an input of 14926 biscuits,

it should output

It takes 11 truck(s), 4 container(s), and 17 box(es) to store the order

There are 6 leftover biscuits

For input 8163 biscuits,

it should output

It takes 6 truck(s), 2 container(s), and 16 box(es) to store the order

There are 3 leftover biscuits

5 points extra credit if your output looks EXACTLY as above

Explanation of Calculation

To determine the number of trucks, you are dividing the number of biscuits by how many a truck can store.

Take a 2950 biscuit order as an example,

2950 / 1250 gives you 2. So 2950 biscuits will need 2 trucks, which can store 2500 biscuits

There are 450 biscuits leftover. This cannot fill a truck so you find how many containers

similar process as above

450 / 250 gives you 1. So 450 biscuits will need 1 container which can store 250 of the biscuits

There are 200 biscuits left. (and so on and so forth)   

Solutions

Expert Solution

#include <iostream>
using namespace std;
int main()
{
    int Biscuits;
    int trucks,containers,Biscuits_left,boxes=0; //intially all variables are taken as zero.
    cout << "Enter No of Biscuits:";
    cin >> Biscuits;
    trucks = Biscuits/1250; // calculates the trucks needed.
    Biscuits_left = Biscuits % 1250; // % used to calculate biscuits left after calculating the trucks needed.


    
    if(Biscuits_left>0) // it checks for the any buscits left
    {  
           containers =  Biscuits_left/250;
           Biscuits_left = Biscuits_left%250;
           if(Biscuits_left>0) // executes when any biscuits left after calculating the containers.
          { 
             boxes = Biscuits_left/10;
              Biscuits_left = Biscuits_left%10; //caluates the final result for biscuits left
            
             cout << " it takes " << trucks << " truck(s), " << containers <<" container(s), and " <<  boxes <<" Box(es) to store the order";
             cout <<"\n There are " << Biscuits_left <<" biscuits left";
          }
     }
    else // executes when there are no biscuits left after calculating the trucks
    { 
          cout << " it takes " << trucks << " truck(s), " << containers <<" container(s), and " <<  boxes <<" Box(es) to store the order";
          cout <<"\n There are " << Biscuits_left <<" biscuits left";
    }
    
    return 0;
}
output:
 
Enter No of Biscuits:14946
 it takes 11 truck(s), 4 container(s), and 19 Box(es) to store the order
 There are 6 biscuits left

Enter No of Biscuits:1250
 it takes 1 truck(s), 0 container(s), and 0 Box(es) to store the order
 There are 0 biscuits left

Enter No of Biscuits:151678
 it takes 121 truck(s), 1 container(s), and 17 Box(es) to store the order
 There are 8 biscuits left


Related Solutions

Explain how a cap-and-trade program works.
Explain how a cap-and-trade program works.
Your final project will satisfy the following scenario: You are writing a program that will act...
Your final project will satisfy the following scenario: You are writing a program that will act as an ATM machine by the end of this course. In order to access the ATM, the customer must enter their user name and their passcode. After 3 incorrect attempts at entering the user name and password, the program will end. The list of legitimate users along with their user ID, passcode, and account balance will be provided to you. There are only 5...
Understand the code and explain the code and answer the questions. Type your answers as comments....
Understand the code and explain the code and answer the questions. Type your answers as comments. #include #include using namespace std; // what is Color_Size and why it is at the end? enum Color {        Red, Yellow, Green, Color_Size }; // what is Node *next and why it is there? struct Node {        Color color;        Node *next; }; // explain the code below void addNode(Node* &first, Node* &last, const Color &c) {        if (first == NULL)...
Use the Beer-Lambert law to explain how a colorimetric assay works in the spectrophotometer. In your...
Use the Beer-Lambert law to explain how a colorimetric assay works in the spectrophotometer. In your answer, define the following terms; chromophore, extinction coefficient, absorbance, transmission and reagent blank. Most of the spectrophotometers in the teaching lab emit light of wavelengths between 400-700nm. However some spectrophotometers also emit light between 200-400nm. Why is this extended range useful? Provide a specific example. How can you use a spectrophotometer to perform a qualitative analysis of a substance?
*DO NOT ROUND OFF ANY ANSWER UNTILL YOUR FINAL ANSWER. ROUND YOUR FINAL ANSWER TO THE...
*DO NOT ROUND OFF ANY ANSWER UNTILL YOUR FINAL ANSWER. ROUND YOUR FINAL ANSWER TO THE NEAREST WHOLE DOLLAR* Present value of an ordinary annuity periods       3          5          9         10 4%               2.77    4.45    7.43    8.11 8%               2.57    3.99    6.25    6.71 On april 1,2020, ABC company rendered services to jones company in exchange for 3 year $400000 ,8% note. Payments of P&I (principal & interest) are due each april 1st, with the first payment due immediately. December 31st is the fiscal...
*Do not round any answer until your final answer. Round your final answer to the nearest...
*Do not round any answer until your final answer. Round your final answer to the nearest whole dollar. When entering your final answer, do not use commas or $ sign. (Sorry...Canvas is very sensitive and will mark your answer incorrect due to rounding and punctuation.) Due to possible rounding differences, all answer solutions are programmed as acceptable that are +/- 1. For example, if the correct answer is $54,372, all possible answer solutions that would be accepted would be 54,371,...
JAVA CODE BEGINNER , Please use comments to explain, please Repeat the calorie-counting program described in...
JAVA CODE BEGINNER , Please use comments to explain, please Repeat the calorie-counting program described in Programming Project 8 from Chapter 2. This time ask the user to input the string “M” if the user is a man and “W” if the user is a woman. Use only the male formula to calculate calories if “M” is entered and use only the female formula to calculate calories if “W” is entered. Output the number of chocolate bars to consume as...
Explain how the IRR works and how this is used to help evaluation a potential project....
Explain how the IRR works and how this is used to help evaluation a potential project. What is the conclusion when the IRR is below the cost of capital of a project? What about when it is greater than the cost of capital? In what way is the MIRR more accurate than the IRR in evaluating a project?
If you were to implement a research project to answer your clinical or management question: How...
If you were to implement a research project to answer your clinical or management question: How will you ensure that ethical principles are fostered? What statistical analyses would you incorporate?
Must show all needed steps in getting to your final answer. And, express your final answer...
Must show all needed steps in getting to your final answer. And, express your final answer as a decimal. Show every step NEATLY please NEATLY AND VERY CLEAR AND READABLE PLEASE TYPE ANSWER AND WORK NEATLY AND VERY CLEAR AND READABLE PLEASE TYPE ANSWER AND WORK Part 1) Suppose that you are planning to travel a certain air route via plane once each week for your new job. Also, assume that there is a 3% chance that your outbound flight...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT