Concept explainers
A metric ton is 35,273.92 ounces. Write a
List of variables:
ounces: Store the weight of the breakfast meal in ounces.
result: Store the weight in metric tons.
List of functions used:
ceil(): Calculate the ceiling value of the function.
cin(): To take input from input streams like keyboard, files, etc.
cout(): To display the output.
Summary Introduction:
Program will use Main () method to prompt the user to enter the weight of the breakfast meal in ounces and convert it into metric tons and also find the number of boxes needed to yield one metric ton of cereal.
Program Description:
Purpose of program is to find the weight in metric tons and also find the number of boxes needed to yield one metric ton of cereal.
Explanation of Solution
Program:
Following is the C++ program to find the weight in metric tons, and to find the number of boxes needed to yield one metric ton of cereal.
#include <iostream> #include <cmath> using namespace std; int main() { float ounces; cout<< "Enter the weight of the breakfast meal in ounces: "; cin>> ounces; // Conversion from ounces to metric tons float result = ounces/35273.92; cout<<endl; cout<< "The weight of the package of breakfast in metric ton is : " << result; cout<<endl; cout<< "The number of boxes needed to yield the one metric ton of cereal are: " << ceil(1/result); cout<<endl; return 0; }
Explanation:
In the above program,the user prompts the weight of the breakfast meal in ouncesand the formula to convert the weight from ounce to metric ton is used. The number of boxes needed is the reciprocal of the weight in metric tons. Then cout() function is used to show the output of the program.
Sample Output:
Following is the sample output for the given program:
Enter the weight of the breakfast meal in ounces: 350 The weight of the package of breakfast in metric ton is : 0.00992235 The number of boxes needed to yield the one metric ton of cereal are : 101
Want to see more full solutions like this?
Chapter 1 Solutions
Absolute C++
Additional Engineering Textbook Solutions
Java How To Program (Early Objects)
Starting Out With Visual Basic (8th Edition)
Starting Out with Python (4th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with C++: Early Objects (9th Edition)
- Write a program using inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for women and men.arrow_forwardWrite a program that takes as input the speed of a car e.g 80. If the speed is less than 70, it should print “Ok”. Otherwise, for every 5 km/s above the speed limit (70), it should give the driver one demerit point and print the total number of demerit pointsarrow_forwardWrite a program with total change amount in pennies as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimesarrow_forward
- Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimesarrow_forward(C++) Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Penniesarrow_forwardWrite a program that will Input the name , position of the employee , Input the rate per hour, hours worked. Compute the Gross pay for an employee.arrow_forward
- Write a program to read two integers with the following significance. The first integer value represents a time of day on a 24-hour clock, so that 1245 represents quarter to one mid-day, for example. The second integer represents a time duration in a similar way so that 345 represents three hours and 45 minutes. This duration is to be added to the first time, and the result printed out in the same notation, in this case, 1630 which is the time 3 hours and 45 minutes after 12:45. Another example is given below. Example:Enter in a start time: 1415Enter in a duration: 50End time is: 1505arrow_forwardWrite a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: intdollar, quarters, dimes, nickels, pennies; printf("Enter due amount: ");scanf("%d", &due); printf("Enter paid amount: ");scanf("%d", &amount); change(amount - due, &dollar, &quarters, &dimes, &nickels, &pennies); printf("Dollars: %d\n", dollar);printf("Quarters: %d\n", quarters);printf("Dimes: %d\n", dimes);printf("Nickels: %d\n", nickels);printf("Pennies: %d\n", pennies);return0;} //function definationvoid change(int amount, int *dollar, int *quarters, int *dimes, int *nickels, int *pennies){*dollar = amount / 100;amount = amount % 100;*quarters = amount / 25;amount = amount % 25;*dimes = amount / 10;amount = amount % 10;*nickels = amount / 5;amount = amount…arrow_forwardWrite a program to read a positive integer value and to output the bonus received by the user. A game consists of selecting a positive integer value and rewarding bonuses to the player according to the remainder in the division of that integer value by 4 as follows: REMAINDER BONUS 0 200 1 350 2 400 3 500arrow_forward
- Write a program with total change amount (in cents) as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Hint: Start from the largest denomination. Divide the change amount by the number of cents in the denomination to get the number of coins used. The remainder of the division is used to find the number of coins used in the next denomination. Ex: value // 100 gives the number of dollars used. The remainder is divided by 25 to find the number of quarters used. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimesarrow_forwardWrite a program that computes the cost of postage on a first-class letter according to the followingrate scale: 105 cents for the first gram or fraction of a gram, 35 cents for each additional half gram,plus a $ 15 service charge if the customer desires special delivery. Note: any partial gram increasewill add 35 cent. For example 1.1 g and 1.5 g will cost 105 +35 = 140 cents $ 1.40arrow_forwardWrite a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes ''' Type your code here. '''arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education