The Way to Programming
The Way to Programming
C++ program for interior decorators to calculate the estimate cost of painting a room
I have a friend that needs this little project done rather urgently.. Below is what’s required. I would really appreciate if some gifted person could knock this one out.. Thank you so much!!
With the help of functions, design a program for interior decorators to calculate the estimate cost of painting a room.
The program should accept the input of height of the room (between 4 and 6 meters), and the length of all four walls(minimum 2 meters, maximum 15 meters). The program should then calculate the total area of that room. the program should allow decorators with a choice of three paints:
– Economy, cost $1.00 per Square meter
– Standard, cost $1.50 per Square meter
– Luxury, cost $1.95 per Square meter
The program should then ask the decorator to enter an estimated variation (between 2% and 5%) in the total cost price
Demonstrate the use of variables, conditionals, loops and iteration.
#include#include // function and declaration of variables float cal_area(float height, float length) { // when the function is called it will return the result of height multiplied by length return (height * length); } // function and declaration of variables float cal_cost(float area, float cost) { // when the function is called it will return the result of area multiplied by cost return (area * cost); } float vari_cal (float variation) { return (variation/100); } main() { int option; float height,length,Area,Cost; float variation; cout<<"Hello welcome to paint a room\n\n"; cout<<"Please enter the height of room --> "; cin>>height; cout<<"Please enter the lenght of the walls --> "; cin>>length; if (height < 4 || height > 6 || length < 2 || length > 15) { cout<<"\nWrong input\n"<<"Please try later\n"; } else { Area = cal_area(height, length); cout <<"\nArea of room is --> "< "; cin>>option; if (option == 1) { Cost = cal_cost(Area, 1.0); cout<<"\n\nThe cost of painting the room is --> "< >variation; float Cost_with_variation = vari_cal + Cost; } else if (option == 2) { Cost = cal_cost(Area, 1.5); cout<<"\n\nThe cost of painting the room is --> "< >variation; } else if (option == 3) { Cost = cal_cost(Area, 1.95); cout<<"\n\nThe cost of painting the room is --> "< >variation; } else if (option == 4) { break; } else { cout<<"\nPlease select an option between 1 and 4"; } } while(option!=4); }}
Here you go
#include#include using namespace std; // function and declaration of variables float cal_area(float height, float length) { // when the function is called it will return the result of height multiplied by length return (height * length); } // function and declaration of variables float cal_cost(float area, float cost) { // when the function is called it will return the result of area multiplied by cost return (area * cost); } float vari_cal (float variation) { return (variation/100); } int main() { int option; float height,length,Area,Cost; float variation; cout<<"Hello welcome to paint a room\n\n"; cout<<"Please enter the height of room --> "; cin>>height; while(height < 4 || height > 6) { cout << "Height must be between ( 4 - 6)" << endl; cout<<"Please enter the height of room --> "; cin>>height; } cout<<"Please enter the lenght of the walls --> "; cin>>length; while (length < 2 || length > 15) { cout << "Length must be between ( 2 - 15)" << endl; cout<<"Please enter the height of room --> "; cin>>height; } Area = cal_area(height, length); cout <<"\nArea of room is --> "< "; cin>>option; if (option == 1) { Cost = cal_cost(Area, 1.0); cout<<"\n\nThe cost of painting the room is --> "< >variation; while(variation < 2 || variation > 5) { cout << "Error in variation ( 2 - 5).." << endl; cout<<"Please enter cost variation %"; cin>>variation; } float Cost_with_variation = vari_cal(variation) + Cost; Cost = cal_cost(Area, 1.5); cout << "Cost with variation --> " << Cost_with_variation << endl; } else if (option == 2) { cout<<"\n\nThe cost of painting the room is --> "< >variation; while(variation < 2 || variation > 5) { cout << "Error in variation ( 2 - 5).." << endl; cout<<"Please enter cost variation %"; cin>>variation; } Cost = cal_cost(Area, 1.5); float Cost_with_variation = vari_cal(variation) + Cost; cout << "Cost with variation --> " << Cost_with_variation << endl; } else if (option == 3) { Cost = cal_cost(Area, 1.95); cout<<"\n\nThe cost of painting the room is --> "< >variation; while(variation < 2 || variation > 5) { cout << "Error in variation ( 2 - 5).." << endl; cout<<"Please enter cost variation %"; cin>>variation; } Cost = cal_cost(Area, 1.5); float Cost_with_variation = vari_cal(variation) + Cost; cout << "Cost with variation --> " << Cost_with_variation << endl; } else { cout<<"\nPlease select an option between 1 and 4"; } } while(option!=4); }
Sign in to your account