473,396 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

paint program program help I have started the program but need some help with the roo

here is the scenario for the program:

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
  1. // The paint problem
  2. //
  3. #include <iostream>
  4. using namespace std;
  5. //**********************************
  6. int check_height(float height)
  7. {
  8.     if ((height < 2.0) || (height > 6.0))
  9.     {
  10.         cout << "Height must be between 2 and 6 \n";
  11.         return 0;
  12.     }
  13.     return 1;
  14. }
  15. //**********************************
  16. int check_length(float length)
  17. {
  18.     if ((length < 1.0) || (length > 25.0))
  19.     {
  20.         cout << "Height must be between 1 and 25 \n";
  21.         return 0;
  22.     }
  23.     return 1;
  24. }
  25. //**********************************
  26. void area(float& wall_area, float* height, float*length)
  27. {
  28.     cout << "Area of all four walls is = " << (height[0] * length[0]) << "\n";
  29.     wall_area = height[0] * length[0];
  30. }
  31.  
  32. //**********************************
  33. void get_room_dim(float* height, float* length)
  34. {
  35.     int height_ok[4]; // 1 indicates height > 2 and < 6
  36.     int length_ok[4]; // 1 indicated length > 1 and < 25
  37.     height_ok[0] = 0;
  38.     while (height_ok[0] == 0)
  39.     {
  40.         //**********************************************//
  41.         cout << "Please enter height of all four walls 1 between  2 to 6 \n";
  42.         cin >> height[0];
  43.         height_ok[0] = check_height(height[0]);
  44.         if (height_ok[0] != 1)
  45.         {
  46.             cout << "Height = " << height[0] << "\n";
  47.             cout << "It must be between 2 and 6 \n";
  48.         }
  49.     }
  50.     cout << "**********************************************"<<
  51.     length_ok[0] = 0;
  52.     while (length_ok[0] == 0)
  53.     {
  54.         cout << "Please enter length of all four wall 1 between  1 to 25 \n";
  55.         cin >> length[0];
  56.         length_ok[0] = check_length(length[0]);
  57.         if (length_ok[0] != 1)
  58.         {
  59.             cout << "Length = " << length[0] << "\n";
  60.             cout << "It must be between 1 and 25 \n";
  61.         }
  62.     }
  63. }
  64. int main()
  65. {
  66.     float height[4], length[4];
  67.     float wall_area;
  68.     cout << " ********************************** Quotations******************************* \n";
  69.     cout << "Hello, new customer \n";
  70.     get_room_dim(height, length);
  71.     area(wall_area, height, length);
  72.     return 0;
  73. }
Question:
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.
Apr 20 '14 #1
1 2246
weaknessforcats
9,208 Expert Mod 8TB
write a function to ask for the undercoat selection and have the function return a value that you store in a variable in main(). You can use the variable in the program to make you undercoat check.

Write a function that returns the area of the room. Use arguments for the length, width, an height of the room. Store the result in a variable in main(). Use it as needed elsewhere in the program.
Apr 22 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: tgregg6 | last post by:
I need help with my problem I am stuck and I don't know what to do!!! The problem is: This program calculates the charges for DVD rentals where current releases cost $3.5 and all others cast $2.50....
16
by: negrito | last post by:
I need help to create this program: This program will take user input in the folowing order: 1.number of tickets sold. 2.percentage of ticket revenue which goes to administrative costs.This input...
6
by: mehly2020 | last post by:
I need help on getting started with a dice program that will output as many random numbers from 1 to 6 and as many rolls as the user requests....And then how many times each number shows up from the...
3
Chrisjc
by: Chrisjc | last post by:
I am not good at VB and I am taking a class for it at ITT... I am doing a program chanllenge and really really need help it is due today... and I am not good at this at all... could some one please...
2
by: Mitchel | last post by:
I don't know exactly whats wrong, my program works, but, I need it to be able to go all the up to "2 to the power of 295 is 6.36574E+88" but my program gives 31 a negitive answer "2 to the power of...
12
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed...
3
by: ashley514 | last post by:
Yeah so I've been taking java programming as an elective course in school and I don't really understand how to use arrays and stuff. He's like flying through this chapter and I'm not picking it up at...
8
by: ImortalSorrow | last post by:
Hey, I'm quite new in programing so need some help with this lottery program I'm making. What I'm trying to do is very simple, simulate a lottery but my effords are in vain since when I'm compiling...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.