cs161AWinter2024/fun1.cpp

59 lines
1000 B
C++

#include <iostream>
using namespace std;
string asker(string prompt){
string s;
cout << prompt << endl;
cin >> s;
return s;
}
string asker(string askPrompt, string thankPrompt){
string s;
cout << askPrompt << endl;
cin >> s;
cout << thankPrompt << endl;
return s;
}
bool yesOrNo2(string prompt){
string input;
cout << prompt << endl;
cin >> input;
// !(input == "yes" || input == "no")
while(input != "yes" && input != "no"){
cout << prompt << endl;
cin >> input;
}
return (input == "yes");
}
bool yesOrNo(string prompt){
// function should display prompt
// then ask for an answer
// return true if answer == "yes"
// return false otherwise
string input;
cout << prompt << endl;
cin >> input;
if(input == "yes"){
return true;
}
else {
return false;
}
}
int main(){
bool answer = yesOrNo2("Are dogs good?");
if(answer){
cout << "Glad you agree" << endl;
}
else{
cout << "...why?" << endl;
}
return 0;
}