C++ help with code

Hi, I need help programming this code with these specific requirements, ive done a part of it already:

Design a C++ program to estimate the cost for painting a room. The user must supply all the necessary information for the room to be painted. The output must list the areas to be painted and the estimated cost for each area and the overall total for the room. The program should allow the user to redo the process with different specifications (either the same room or a different room). It is not necessary to combine the outputs from multiple rooms to a single total.

The ceiling in any room may be white or a color, the walls a light shade of color, and the door and window moldings and baseboards will be either white or a color that is complementary to the color of the walls.

Prompt the user for and read the following:

Length, width and height of the room in feet and inches (you may assume the room is a simple rectangle).
Ceiling paint either white or colored.
The number and size of the windows in inches (a “for” loop is recommended).
The number and size of the doorways in inches (a “while” or “do-while” loop is recommended).
Window and door trim as white or color (note that all trim will be the same).
You will need to convert all the dimensions to either inches or feet for calculations. Store window and door dimensions and areas in separate arrays or, optionally, in a two-dimensional array. Note that window trim covers all four (4) sides of a window, door trim covers only three (3) sides. All calculated fields must be float or double.

Paint for the ceiling and walls will cost $12.50 per gallon; the baseboards and molding will be semi-gloss enamel at $6.50 per quart for white and $8.50 per quart for colors. Coverage rates are approximately 250 square feet per gallon of ceiling and wall paint and 100 square feet per quart of enamel.

After accepting the required inputs, clear the screen and display the results. After displaying the results, prompt the user to determine if another attempt (or room) is to be done. If the response is “Y[es]”, clear the screen and restart the input process, if “N[o]”, terminate the program; if neither, re-prompt the user for a correct response.

Programming requirements:

Use only standard structured techniques.
Program must make full use of functions.
The main function should only control the overall program logic.
Screen should be cleared between room input and output displays.
All screen displays must contain appropriate text.
Program must be repetitive until terminated by user.
Sample input process:

Enter room length in feet and inches: 20 9

Enter room width in feet and inches: 12 6

Enter room height in feet and inches: 7 11

How many windows are there in the room: 3

Enter width and height for window 1 in inches: 90 36

Enter width and height for window 2 in inches: 24 36

Enter width and height for window 3 in inches: 24 36

How many doors are there in the room: 2

Enter width and height for door 1 in inches: 30 84

Enter width and height for door 2 in inches: 30 84

Is the ceiling to be in C[olor] or W[hite]? : W

Enter the height of the baseboard: in inches: 4.5

Is the baseboard to be in C[olor] or W[hite]? : C

Enter the height of the trim in inches: 2.5

Is the trim to be in C[olor] or W[hite]? : C





Sample output process:

Room wall area: xxxx sq. ft.

Ceiling area: xxxx sq. ft.

Door and window trim: xxxx sq.ft.

Baseboard trim: xxxx sq. ft.

White paint: xx gallons; $xx.xx

Color paint: xx gallons; $xx.xx

White trim paint: x quarts; $xx.xx

Color trim paint: x quarts; $xx.xx

Total paint cost: $xxx.xx



Repeat the process for this or another room? B

You must respond with Yes or No!

Repeat the process for this or another room? N




#include <iostream>
using namespace std;

const float SQUARE_INCHES_TO_SQUARE_FEET=144;

float convertFeetAndInchesToFeet(float feet, float inches){
float inchesToFeet=inches/12.0;
float feetConversion=feet+inchesToFeet;


return feetConversion;
}

int main(){
float roomLenghtFeet=0;
float roomLengthInches=0;
float roomLengthInFeet=0;

float roomWidthFeet=0;
float roomWidthInches=0;
float roomWidthInFeet=0;

float roomHeightFeet=0;
float roomHeightInches=0;
float roomHeightInFeet=0;

float lengthSideOfWallArea=0;
float widthSideOfWallArea=0;
float totalWallArea=0;
//Window Variables
int numberOfWindows=0;

cout<<"Enter the room length in feet and in inches"<<endl;
cin>>roomLenghtFeet;
cin>>roomLengthInches;

cout<<"Enter the room width in feet and in inches"<<endl;
cin>>roomWidthFeet;
cin>>roomWidthInches;

cout<<"Enter the room height in feet and in inches"<<endl;
cin>>roomHeightFeet;
cin>>roomHeightInches;

//find total wall area
//convert room lenght to feet and inches to feet only

roomLengthInFeet = convertFeetAndInchesToFeet(roomLenghtFeet, roomLengthInches);
roomWidthInFeet = convertFeetAndInchesToFeet(roomWidthFeet, roomWidthInches);
roomHeightInFeet = convertFeetAndInchesToFeet(roomHeightFeet, roomHeightInches);

lengthSideOfWallArea=roomLengthInFeet*roomHeightInFeet;
widthSideOfWallArea=roomWidthInFeet*roomHeightInFeet;
totalWallArea=(lengthSideOfWallArea*2)+(widthSideOfWallArea*2);
cout<<"The total wall area is "<<totalWallArea<<endl;

//get window data

cout<<"How many windows are there in the room"<<endl;
cin>>numberOfWindows;
float windowLengthsInInches[numberOfWindows];
float windowWidthsInInches[numberOfWindows];
float windowAreas[numberOfWindows];

for(int i=0;i<numberOfWindows;i++){
cout<<"Enter length of window "<<i+1<<" in inches"<<endl;
cin>>windowLengthsInInches[i];

cout<<"Enter width of window "<<i+1<<" in inches"<<endl;
cin>>windowWidthsInInches[i];

windowAreas[i]=(windowLengthsInInches[i]*windowWidthsInInches[i])/SQUARE_INCHES_TO_SQUARE_FEET;

cout<< "Area of Windows "<<i+1<<" is"<<windowAreas[i]<<endl;

}


}
closed account (DjA9E3v7)
After accepting the required inputs, clear the screen and display the results. After displaying the results, prompt the user to determine if another attempt (or room) is to be done. If the response is “Y[es]”, clear the screen and restart the input process, if “N[o]”, terminate the program; if neither, re-prompt the user for a correct response.

Have you implemented this part of your program?
Hello Panto,

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

I will suggest that you reread the instructions you have been given. Because your first bit of code does not follow the instructions.
The main function should only control the overall program logic.
You are trying to do all of your input in main when it should be done in functions.

I also noticed three lines that will not work:
1
2
3
float windowLengthsInInches[numberOfWindows];
float windowWidthsInInches[numberOfWindows];
float windowAreas[numberOfWindows];

these arrays either need to be created dynamically here or at the beginning of the program with a constant number for the array size.

Hope that helps,

Andy
Topic archived. No new replies allowed.