A batch of concrete is made using the following materials *cement=30,000kg *Sand=50,000kg *Gravel=17,500kg *Water=3000kg a)Write a C++ program code to calculate and display the amount of sand in a real number and a percentage of the total mass of concrete. b)The amount of water in real number,and a percentage of the amount of cement.
#include <iostream>
using namespace std;
int main() {
float cement=30000;
float sand=50000;
float gravel=17500;
float water=3000;
//calculate and display the amount of sand in a real number and a percentage of the total mass of concrete.
float totalMass=cement+sand+gravel+water;
float percentageTotalMass=(sand/totalMass)*100.0;
float percentageCementTotalMass=(cement/totalMass)*100.0;
cout<<"The amount of sand in a real number: "<<sand<<"\n";
cout<<"A percentage of the total mass of concrete: "<<percentageTotalMass<<"%\n";
//The amount of water in real number,and a percentage of the amount of cement
cout<<"The amount of water in a real number: "<<water<<"\n";
cout<<"A percentage of the amount of cement: "<<percentageCementTotalMass<<"%\n";
cin>>cement;
return 0;
}
Comments
Leave a comment