編集:私のコードにリビジョンを作成した後、それは正常に動作します。私はC++を初めて使っているので、あなたの一部が正しく見えず、エラーや倫理的でないものが見つかるかもしれないと確信しています。このプログラムで改善できることがあれば教えてください。このcin
文のソリューションを見つけることができません
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main() {
// CUSTOMER TYPE
string customertype;
string classtype;
string difficultytype;
// CLASS TYPE
string ballet;
string salsa;
string bollywood;
// DIFFICULTY TYPE
float beginner = 0;
float intermediate = 0;
float advanced = 0;
// CUSTOMER TYPE INPUT
cout << "Enter Customer Type: ";
cin >> customertype;
if (customertype == "concession") {
} else if (customertype == "child") {
} else if (customertype == "adult") {
} else
cout << "\n\tInvalid Choice" << "\n" << endl;
// CLASS TYPE INPUT
cout << "Enter Class Type: ";
cin >> classtype;
if (classtype == "ballet") {
} else if (classtype == "salsa") {
} else if (classtype == "bollywood") {
} else
cout << "\n\tInvalid Choice" << "\n" << endl;
// DIFFICULTY TYPE INPUT
cout << "Enter Difficulty Level: ";
cin >> difficultytype;
if (difficultytype == "beginner") {
} else if (difficultytype == "intermediate") {
} else if (difficultytype == "advanced") {
} else
cout << "\n\tInvalid Choice" << "\n" << endl;
// CALCULATION
float totalprice = 0;
if ((customertype == "concession") && (difficultytype == "beginner" && "intermediate" && "advanced")) {
cout << "\n\tTotal Price: 2.50" << "\n" << endl;
} else if ((customertype == "child") && (difficultytype == "beginner")) {
cout << "\n\tTotal Price: 2.50" << "\n" << endl;
} else if ((customertype == "child") && (difficultytype == "intermediate")) { cout << "\n\tTotal Price: 3.50" << "\n" << endl;
} else if ((customertype == "child") && (difficultytype == "advanced")) {
cout << "\n\tTotal Price: 4.00" << "\n" << endl;
} else if ((customertype == "adult") && (difficultytype == "beginner")) {
cout << "\n\tTotal Price: 4.00" << "\n" << endl;
} else if ((customertype == "adult") && (difficultytype == "intermediate")) { cout << "\n\tTotal Price: 5.00" << "\n" << endl;
} else if ((customertype == "adult") && (difficultytype == "advanced")) {
cout << "\n\tTotal Price: 5.50" << "\n" << endl;
} else
cout << "\tInvalid Choice" "\n" << "\n" << endl;
cout << "\n\tCustomer Type: " << customertype << "\n" << endl;
cout << "\n\tClass Type: " << classtype << "\n" << endl;
cout << "\n\tDifficulty Type: " << difficultytype << "\n" << endl;
system("pause");
return 0;
}
あなたは[良いC++の本](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list)を使うことができるような音がします。 'cin >>譲歩、子供、大人;'あなたが思っていることはしません。 – NathanOliver
@ NathanOliver私はそれが譲歩、子供、大人のどちらかとしてのインプットを取るという印象を受けていますか?私が間違っているなら、私を修正してください。 – FutureProgrammer
いいえ、カンマ演算子です。この場合、 '' cin >> concession''だけが何かをするものです。 '、子、大人;'は基本的に無視されます。参照:https://en.wikipedia.org/wiki/Comma_operator – NathanOliver