To prevent issues similar to that, I ask my kids "Do you want cake exclusive or ice cream?" I'm not letting them get away with any of this nonsense.
Unrelated, I think ohsnap should replace helloworld as the "basic" program. ohsnap would allow you to demonstrate while loops, input, and display. Here it is in python.
#ohSnap.py
#Pro Sandy
#Python 3, ver: 3.3.2
#Wing IDE 101, 5.0.1-1 (rev 30370)
#Program determines if an "Oh, snap!" is appropriately warranted.
def ohSnap():
YES = ["YES", "Y"]
NO = ["NO", "N"]
YNOPTIONS = YES + NO
while True:
toldCheck = input("Did someone get told? ")
if toldCheck.upper() in YNOPTIONS:
if toldCheck.upper() in YES:
print("Oh, snap!\n")
break
else:
print("Tell them.\n")
else:
print("Invalid input. You got told.")
Now in C++
//ohSnap.cpp
//Pro Sandy
//C++
//Microsoft Visual C++ 2010 Express Ver. 10.0.30319.1
//Determines if Oh, Snap! is warranted.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
void ohSnap (){
string told;
string yes = "yes";
string no = "no";
cout << "Was someone told? ";
getline (cin, told);
if(told == yes){
cout << "Oh snap!" << endl;
}
else if(told == no){
cout << "Tell them." << endl;
}
else{
cout << "Invalid input. You got told." << endl;
}
return;
}
int main(){
ohSnap();
return 0;
}
Finally, Prolog.
%ohSnap.pl
%
%Pro Sandy
%Created: February 1, 2014
%
%Written in Microsoft Windows Notepad
%Developed for and tested using SWI-Prolog version 7.1.5
%
%This program runs on query.
%
%This program query's the user to determine if the use of Oh Snap is warranted.
ohSnap(oh_snap) :-
told(yes),
!.
ohSnap(tell_them) :-
told(no),
!.
ohSnap(invalid_input_you_got_told) :-
told(C).
getTold :-
write('Did someone get told?: '),
read(A),
nl,
assert(told(A)).
query :-
retractall(told(A)),
getTold,
ohSnap(B),
write(B),
nl.
#__main__
if __name__ == "__main__":
ohSnap()