Kairi's code
unknown
c_cpp
4 years ago
1.4 kB
4
Indexable
#include <iostream> int main() { int nRooms, nWallSpace; float paintCost; std::cout << "How many rooms will be painted? >> "; std::cin >> nRooms; if (nRooms < 1) { std::cout << "Error: Number of rooms needs to be at least 1.\n"; return 1; } std::cout << "How much does the paint cost per gallon? >> "; std::cin >> paintCost; if (paintCost < 10) { std::cout << "The paint cannot cost less then RM 10.00\n"; return 1; } std::cout << "How many square feet of wall space per room? >> "; std::cin >> nWallSpace; if (nWallSpace < 0) { std::cout << "Wall space cannot be negative.\n"; return 1; } // Units will be rounded up float nUnits = float(nWallSpace) / 115; float nGallonsOfPaint = nUnits; float workHours = nUnits * 8; float totalPaintCost = paintCost * nGallonsOfPaint; float totalPaintJobCost = workHours * 25; std::cout << "Number of gallons of paint required: " << nGallonsOfPaint << "\n"; std::cout << "Hours of labor required: " << workHours << "\n"; std::cout << "Total cost of the paint: " << totalPaintCost << "\n"; std::cout << "Labor charges: R$ 25.00 per hour of labor\n"; std::cout << "Total paint job cost: " << totalPaintJobCost << "\n"; return 0; }
Editor is loading...