A local interior decorator has asked you to design a program in C to estimate the cost of painting a room. The decorator needs to enter the height of the room (between 2 and 6 meters), then the length of all four walls (minimum 1 meter; maximum 25 meters). The program should then calculate the total area of the room.
The program should allow a choice of three paints:
• Luxury quality which costs £1.75 per square meter
• Standard quality which costs £1.00 per square meter
• Economy quality which costs £0.45 per square meter
The decorator should also be able to choose to use undercoat paint if required, which costs an addition £0.50 per square meter.
All inputs need to be validated to prevent erroneous values being entered and your program needs to provide clear, onscreen help to assist the user.
I have started the program but need some help with the undercoat, paint selection, the area of the room and the total.
Here is my programming code:
Expand|Select|Wrap|Line Numbers
- // The paint problem
- //
- #include <iostream>
- using namespace std;
- //**********************************
- int check_height(float height)
- {
- if ((height < 2.0) || (height > 6.0))
- {
- cout << "Height must be between 2 and 6 \n";
- return 0;
- }
- return 1;
- }
- //**********************************
- int check_length(float length)
- {
- if ((length < 1.0) || (length > 25.0))
- {
- cout << "Height must be between 1 and 25 \n";
- return 0;
- }
- return 1;
- }
- //**********************************
- void area(float& wall_area, float* height, float*length)
- {
- cout << "Area of all four walls is = " << (height[0] * length[0]) << "\n";
- wall_area = height[0] * length[0];
- }
- //**********************************
- void get_room_dim(float* height, float* length)
- {
- int height_ok[4]; // 1 indicates height > 2 and < 6
- int length_ok[4]; // 1 indicated length > 1 and < 25
- height_ok[0] = 0;
- while (height_ok[0] == 0)
- {
- //**********************************************//
- cout << "Please enter height of all four walls 1 between 2 to 6 \n";
- cin >> height[0];
- height_ok[0] = check_height(height[0]);
- if (height_ok[0] != 1)
- {
- cout << "Height = " << height[0] << "\n";
- cout << "It must be between 2 and 6 \n";
- }
- }
- cout << "**********************************************"<<
- length_ok[0] = 0;
- while (length_ok[0] == 0)
- {
- cout << "Please enter length of all four wall 1 between 1 to 25 \n";
- cin >> length[0];
- length_ok[0] = check_length(length[0]);
- if (length_ok[0] != 1)
- {
- cout << "Length = " << length[0] << "\n";
- cout << "It must be between 1 and 25 \n";
- }
- }
- }
- int main()
- {
- float height[4], length[4];
- float wall_area;
- cout << " ********************************** Quotations******************************* \n";
- cout << "Hello, new customer \n";
- get_room_dim(height, length);
- area(wall_area, height, length);
- return 0;
- }
how do I add make the program add a undercoat selection, a paint selection I also want the program to calculate the height, length and area of the room.