# Answer to Question #24640 in C++ for red rose

Question #24640
A balance has the following size weights: 100 lb, 50 lb, 10 lb, 5 lb, and 1 lb. The number of 100 lb and 50 lb weights required to weigh an object weighing weight pounds can be calculated by using the following C++ statements: // Determine the number of 100 lb weights w100 = int(weight/100) // Determine the number of 50 lb weights w50 = int((weight &ndash; w100 * 100)/50) Using these statements as a starting point, write a C++ program that accepts a weight input from the user and then calculates the number of each type of weight needed to weigh that object.
#include<string>
#include<iostream>
using namespace std;
& &
int main (){

int w100,w50,w10,w5,w1,a;

cout<<"enter the weight: ";
cin>>a;
w100=a/100;
a=a-w100*100;

w50=a/50;
a=a-w50*50;

w10=a/10;
a=a-w10*10;

w5=a/5;
a=a-w5*5;

w1=a;

cout<<"100 lb ---- "<<w100<<endl;

cout<<"50 lb ---- "<<w50<<endl;

cout<<"10 lb ---- "<<w10<<endl;

cout<<"5 lb ---- "<<w5<<endl;

cout<<"1 lb ---- "<<w1<<endl;

&
system("PAUSE"); &
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!