嗨我需要帮助构建具有特定要求的程序。我已经开始但只是需要帮助完成

时间:2016-11-22 05:21:08

标签: c++

设计一个C ++程序来估算绘画房间的成本。用户必须提供要绘制的房间的所有必要信息。输出必须列出要绘制的区域以及每个区域的估计成本和房间的总体总数。该程序应允许用户使用不同的规范(同一房间或不同的房间)重做该过程。没有必要将多个房间的输出组合成一个总数。

任何房间的天花板可能是白色或颜色,墙壁是浅色调,门窗模制品和踢脚板将是白色或与墙壁颜色互补的颜色。

提示用户阅读以下内容:

房间的长度,宽度和高度,以英尺和英寸为单位(您可以假设房间是一个简单的矩形)。 天花板漆白色或彩色。 以英寸为单位的窗口数量和大小(建议使用“for”循环)。 门口的数量和大小以英寸为单位(建议使用“while”或“do-while”循环)。 窗户和车门装饰为白色或彩色(请注意,所有装饰都是相同的)。 您需要将所有尺寸转换为英寸或英尺进行计算。将窗口和门的尺寸和区域存储在单独的阵列中,或者可选地存储在二维阵列中。请注意,窗户装饰覆盖了窗户的所有四(4)个侧面,车门装饰仅覆盖三(3)个侧面。所有计算字段必须为float或double。

天花板和墙壁的油漆每加仑12.50美元;底板和成型将是半光泽珐琅,白色每夸脱6.50美元,颜色每夸脱8.50美元。覆盖率约为每加仑天花板和墙面漆250平方英尺,每夸脱搪瓷100平方英尺。

接受所需输入后,清除屏幕并显示结果。显示结果后,提示用户确定是否要进行另一次尝试(或房间)。如果响应是“Y [es]”,清除屏幕并重新开始输入过程,如果“N [o]”,则终止程序;如果不是,请重新提示用户正确的回复。

编程要求:

仅使用标准结构化技术。 程序必须充分利用功能。 主要功能应该只控制整个程序逻辑。 应在房间输入和输出显示之间清除屏幕。 所有屏幕显示必须包含适当的文本。 程序必须重复,直到被用户终止。

示例输入流程:

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

示例输出流程:

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;

    }


}

1 个答案:

答案 0 :(得分:0)

我猜你上面编写的代码会出现编译错误: 我在你的代码中注意到你使用不是常数的变量来定义数组:

this.state.fulldata.forthem.map(function(fakeit,i){

   fakeit.articles.map(function(article,j){

   })   
})

从用户那里获取cout<<"How many windows are there in the room"<<endl; cin>>numberOfWindows; float windowLengthsInInches[numberOfWindows]; 并动态分配数组。