473,466 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

1 New Member
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 2249
weaknessforcats
9,208 Recognized Expert Moderator Expert
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.