Absolute C++ (6th Global Edition) - Does Not Include Myprogramminglab
Absolute C++ (6th Global Edition) - Does Not Include Myprogramminglab
6th Edition
ISBN: 9780134225395
Author: Walter Savitch, Kenrick Mock
Publisher: Pearson Global Edition
bartleby

Concept explainers

bartleby

Videos

Textbook Question
100%
Book Icon
Chapter 1, Problem 1PP

A metric ton is 35,273.92 ounces. Write a program that will read the weight of a package of breakfast cereal in ounces and output the weight in metric tons as well as the number of boxes needed to yield one metric ton of cereal.

Expert Solution & Answer
Check Mark
Program Plan Intro

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?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Write a program that calculates the change due a customer by denomination; that is, how many pennies, nickels, dimes, etc. are needed in change. The input is to be the purchase price and the size of the bill tendered by the customer ($100, $50, $20, $10, $5, $1)
Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and E, possibly followed by + or -. Their numeric values are 4, 3, 2, 1, and 0. There is no F+ or F-. A + increases the numeric value by O.3, a – decreases it by 0.3. However, an A+ has value 4.0. Enter a letter grade: B- The numeric value is 2.7.
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:

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY