Assignment csc201 1
Assignment csc201 1
Level: 200
ASSIGNMENT 1
a) Write a C++ program to find the total amount of cost the bricklayer bought the items.
b) Write a C++ program to find out the balance he will receive if he paid 100 million naira to the
cashier.
c) How many tippers of sand will he buy if a tipper of sand is 5,000 naira?
d) Write a C++ program to find out how many bags of cement he will buy, if one bag of cement is
4,200.
SOLUTION!
A) #include <iostream>
B) using namespace std;
int main() {
cout << "Total amount of cost the bricklayer bought the items: " << totalCost << " naira" << endl;
return 0;
}
b) code to find the balance he will receive if he paid 100 million naira to the cashier
#include <iostream>
using namespace std;
int main() {
int totalAmountPaid = 100000000;
int totalCost = 2000000 + 7000000 + 3000000 + 600000;
cout << "Balance the bricklayer will receive: " << balance << " naira" << endl;
return 0;
}
C) #include <iostream>
D) using namespace std;
E)
F) int main() {
G) // Cost of one tipper of sand
H) int costPerTipper = 5000;
I)
J) // Number of tippers
K) int numberOfTippers = 3000000 / costPerTipper; // 3 million divided by cost per tipper
L)
M) cout << "Number of tippers: " << numberOfTippers << endl;
N)
O) return 0;
P) }
D) #include <iostream>
int main() {
// Cost of one bag of cement
// Number of bags
cout << "Number of bags of cement: " << numberOfBags << endl;
return 0;
}
E) #include <iostream>
int main() {
// Number of bricks
cout << "Number of concrete bricks: " << numberOfBricks << endl;
return 0;
}
2. If a batch of concrete is made up of the following materials:
Cement: 200kg
Sand: 450kg
Granite: 750kg
Write a C++ program to calculate and display, the amount of sand in a real number and the percentage
of the total amount of cement (decimal)
SOLUTION
#include <iostream>
int main() {
cout << "Amount of sand in a real number: " << sandAmount << " kg" << endl;
cout << "Percentage of the total amount of cement (decimal): " << percentageDecimal << "%" << endl;
return 0;
}
3. Two bricks of blocks were tested for water absorption the result are as follows:
Write a c++ program to find the water of each block and the percentage involved.
SOLUTION
#include <iostream>
// Display results
cout << "Block A - Water Absorption: " << waterAbsorptionA << ", Percentage: " << percentageA <<
"%" << endl;
cout << "Block B - Water Absorption: " << waterAbsorptionB << ", Percentage: " << percentageB <<
"%" << endl;
return 0;
}
4. Mary, as the HOC of this class bought the where the prices of these items were displayed for view VAT
of each item included:
If the VAT of each items varies between 5 and 10%, write a C++ program to determine the following:
Determine the total amount of money spent when 1 gallon of kings oil was returned to the market.
SOLUTION
#include <iostream>
int main() {
cout << "Item " << i + 1 << ": Price " << prices[i] << " naira, VAT " << totalVAT << " naira" << endl;
cout << "1. Amount Mary spent: " << totalAmountSpent << " naira" << endl;
cout << "2. Total VAT: " << totalVAT << " naira" << endl;
cout << "3. Transportation cost: " << transportationCost << " naira" << endl;
cout << "Total amount spent after returning 1 gallon of Kings Oil: " << totalAmountSpentAfterReturn
<< " naira" << endl;
return 0;