私はプログラミングに少し新しく、コード全体が一度に実行される理由を理解するのに問題があります。ユーザーに一度に1つのことを尋ねるようにするにはどうすればよいですか?私はそれがとてもシンプルなものだと確信していますが、私はそれを忘れていたに違いありません。ありがとう。プログラムはすべての行を一度に実行します
#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
また、文字列を使用する場合、あなたのヘッダに '#include'が必要です –
Rime