【发布时间】:2018-03-17 16:03:20
【问题描述】:
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
double labor = 3;
double squareFt = 160;
double oneGallon;
double chargePerHour = 28; //charger per hour for labor
double numOfRooms; //input from user
double sqFootage; //input from user
cout<<"Welcome to Artistic Solutions."<<endl;
cout<<"Please enter the number of rooms that will be painted."<<endl;
cin>>numOfRooms);
cout<<"Please enter the squart footage of wall space in each room."<<endl;
cin>>sqFootage);
return 0;
}
这是一项实验室作业,它计算油漆工作的成本。它询问需要粉刷多少个房间以及每个房间的平方英寸。有没有办法关联“numOfRooms”和“sqFootage”?我想做的是尽量减少重复询问每个房间的平方英尺。使用数组和指针会有帮助吗?
【问题讨论】:
-
cin>>sqFootage);你将需要一个循环(并且少一个')')来读取多个房间的平方英尺。停止编写代码,并整理一份你需要做的事情的清单,一份需求文档。一旦你有了这些,找出完成要求所需的顺序,然后你就会更好地了解你真正需要做什么,并希望有一个攻击计划的开始。 -
想想如何使用循环和函数来减少重复。
标签: c++