if else problem und keine eingabe möglich
-
2 sachen funktionieren nicht, und zwar das yes und no eingeben, denn es wird einfach dér ganze text angezeigt und bei if else wird mir immer der fehler angezeigt
Fehler: 'else' without a previous 'if' ....wäre sehr nett wenn jemand helfen könnteint main(){ std::cout << "The Friendship Algorithm By Dr. Sheldon Cooper Ph.D" << std::endl; std::cout << "Place a phone call" << std::endl; std::cout << "Are they home?" << std::endl; int yes; int no; if (no) { std::cout << "Leave Message" << std::endl; std::cout << "Wait for Callback" << std::endl;} else (yes); { std::cout << "Would you like to share a meal?" << std::endl;} std::cout << "Friendship begins" << std::endl; std::cout << "Do you enjoy a hot beverage?" << std::endl; if (yes) { std::cout << "popular choices are tea, coffee, cocoa, which would you prefer?" << std::endl; int coffee; int tea; int cocoa; std::cin >> tea; std::cin >> coffee; std::cin >> cocoa; if (tea); if(coffee); if(cocoa); std::cout << "Friendship begins" << std::endl;} else (no) {std::cout << "Recrealtial activities: Tell me one of your interests" << std::endl;} int HorsebackRiding; int swimming; int RockClimbing; std::cout << "Maybe we can go Horsebackriding?" <<std::endl; if (yes); { std::cout << "Friendship begins" << std::endl;} else (no); { std::cout << "Maybe we can go RockClimbing?" << std::endl; } if (yes); {std::cout << "Friendship begins" << std::endl;} else (no); { std::cout << "Maybe we can go swimming?" << std::endl;} if (yes); { std::cout << "Friendship begins" << std::endl;} else (no); std::cout << "choose least obejectional interest"; if (HorsebackRiding); if (swimming); if (RockClimbing); std::cout << "Friendship begins" << std::endl; // HIER MUSS DIE FOR SCHLEIFE HIN ABER WIEEEE???? std::cout << "Friendship begins" << std::endl; }
-
Du kannst nicht einfach einen Text schreiben, und hoffen dass der Compiler das für dich richtig interpretiert. Oder du kannst schon, aber es wird nicht funktionieren. Der Compiler übersetzt haargenau 1:1 das, was da steht, nach ganz strikten Regeln. Und er versteht keinen Kontext und keine menschlichen Wörter!
Hast du mal daran gedacht, ein Lehrbuch oder einen Programmierkurs zu bemühen?
-
Wie man ein Wort von der Standardeingabe liest und vergleicht ist Dir in Deinem anderen Thread vorgemacht worden. Bitte anwenden. Danke.