Part 1: Find the Maximum and Minimum Weights
You have weight data for several items. Those weights are in pounds and ounces, which are both integer values, like table below.
item | weight |
item1 | 1lb 5oz |
item2 | 32oz |
item3 | 5lb 20oz |
Write a program that will read in the weight of an item in pounds and ounces one by one. Each time after user inputs a weight, the program asks user to input [Y/N] whether user wants to input more weight data. When user say 'N', the program prints the maximum and the minimum weights among the weight data.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CPP OUTPUT
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
cpp codesnap shot:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
cpp code:
#include<bits/stdc++.h>
using namespace std;
int main(){
//step 1: declaring variables
int min_pound = INT_MAX, max_pound = INT_MIN;
int min_ounce = INT_MAX, max_ounce = INT_MIN;
char state='Y';
int pound, ounce;
//step 2 : starting while loop it end when state value changes from
Y
while(state=='Y')
{
//step 3: asking user for weight input
cout<<"Enter the weight in pound"<<endl;
cin>>pound; //loop to take input from the user if he wants to
add more weights
cout<<"Enter the weight in ounce"<<endl;
cin>>ounce;
//step 4:asking user if he wants to add another input
cout<<"Do you want to enter more weight (Y/N)
"<<endl;
cin>>state;
//step 5:converting weight to proper weight
int finalpound=pound+ounce/16;
int finalounce=ounce%16;
//step 6:comparing values and assigning it to min and max
weight
if(min_pound>finalpound){
min_pound=finalpound;
min_ounce=finalounce;
}
if(max_pound<finalpound){
max_pound=finalpound;
max_ounce=finalounce;
}
}
//step 7:printing values
cout<<"min value is "<<min_pound<<" lb
"<<min_ounce<<" oz"<<endl<<"max value is
"<<max_pound<<" lb "<<max_ounce<<"
oz";
//step 8:exiting program
return 0;}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Part 1: Find the Maximum and Minimum Weights You have weight data for several items. Those...
The first programming project involves writing a program that computes the minimum, the maximum and the average weight of a collection of weights represented in pounds and ounces that are read from an input file. This program consists of two classes. The first class is the Weight class, which is specified in integer pounds and ounces stored as a double precision floating point number. It should have five public methods and two private methods: 1. A public constructor that allows...
The first programming project involves writing a program that computes the minimum, the maximum and the average weight of a collection of weights represented in pounds and ounces that are read from a data file. This program consists of two parts. The first part is the Weight class and the second part is the Program Core. The Weight Class is specified in integer pounds and ounces stored as a double precision floating point number. It should have five public methods...
part 1. You measure 24 dolphins' weights, and find they have a mean weight of 36 ounces. Assume the population standard deviation is 13.2 ounces. Based on this, construct a 95% confidence interval for the true population mean dolphin weight. Give your answers as decimals, to two places part 2. Linda draws a heart from a standard deck of 52 cards. She returns the heart to the deck, then draws a second card. Her second card is a spade. Are...
Due: in class Tuesday, 3/27/2018 (upload electronic copy by 9:00am) Problem: You will write a program to compute some statistics about boxes of a popular breakfast cereal called "Chocolate Frosted Sugar Bombs" manufactured by the General Junkfoods Corporation. Automated machinery is used at the company's factory to fill individual boxes with cereal. No machine is perfect, so the amount of cereal actually in a box will vary slightly from box to box. The data file CFSB.txt on the class website...
Programming in C with comments/steps 1. Overview The purpose of this assignment is to give you some experience with writing functions that take in arguments and return values, as well as writing a program that consists of multiple files. This assignment also requires the use of a switch statement, in addition to more practice with printf& scanf declaring variables, using loops, and using logical expressions. For this assignment, you will prompt the user in the main function to enter their...
Nay programming languge is fine (MatLab, Octave, etc.) This is the whole document this last picture i sent is the first page 5. Write and save a function Sphere Area that accepts Radius as input argument, and returns SurfaceArea (4 tt r) as output argument. Paste the function code below. Paste code here 6. Validate your Sphere Area function from the command line, checking the results against hand calculations. Paste the command line code and results below. 7. Design an...
23.4 Project 4: Using Pandas for data analysis and practice with error handling Python Please! 23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same...
23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same as what you had for your chapter 13 labs). The following is an example of...
6.15 Program 6: Using Arrays to Count Letters in Text 1. Introduction In this program, you will practice working with arrays. Your program will read lines of text from the keyboard and use an array to track the number of times each letter occurs in the input text. You will use the contents of this array to generate a histogram (bar graph) indicating the relative frequencies of each letter entered. Test cases are available in this document. Remember, in addition...
18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one part to lab lesson 11. The entire lab will be worth 100 points. Lab lesson 11 part 1 is worth 100 points For part 1 you will have 80 points if you enter the program and successfully run the program tests. An additional 20 points will be based on the style and formatting of your C++ code. Style points The 20 points for coding...