我对编程有点新,并且无法确定整个代码为什么一次运行。我如何制作它,以便一次向用户提供一件事?我确定这件事很简单,但我一定已经忘记了。谢谢。程序每次运行一行
#include<iostream>
using namespace std;
int main()
{
int length;
int width;
int height;
int numberCoats;
int squareFeet;
int name;
int paintNeeded;
int brushesNeeded;
int coatsPaint;
int gallonsPaint;
cout << "Welcome to the program! What is your first name? \n";
cin >> name;
cout << name << " What is the length of the house?";
cin >> length;
cout << name << " What is the width of the house?";
cin >> width;
cout << name << " What is the height of the house?";
cin >> height;
cout << name << " How many coats of paint will it need?";
cin >> coatsPaint;
squareFeet = length * width * height;
paintNeeded = squareFeet/325;
brushesNeeded = squareFeet/1100;
gallonsPaint = coatsPaint * paintNeeded;
cout << name << " , the amount of square feet is " << squareFeet << endl;
cout << name << " , the amount of coats of paint you will need is " << coatsPaint << endl;
cout << name << " , you will need " << gallonsPaint << " of paint" << endl;
cout << name << " , you will need " << brushesNeeded << " of brushes" << endl;
system("pause");
return 0;
}
'name'是一个'int'。这听起来不对。你是否输入了'name'的字符串? –
啊好赶上,你是正确的我马上解决这个问题 – Chad
另外,如果你使用字符串,你需要'#包括'在你的标题 –
Rime