//*************************
//* Project Name: U1-07p.tj
//* Program Name: KK01.cpp
//* Written By: Joshua Thibodeaux
//* Date: 09/12/09
//*
//* This program generates one knock-knock joke and edits the user's responses.
//* Tasks are divided into four functions
//*************************
//**Preprocessor Directives
#include <iostream>
#include <string>
using namespace std;
//Function Proto-types
void getAJoke(string& , string& , string&);
void doJokePart1(string&);
void doJokePart2(string&);
int main()
{
//*****Local Variables and Constants
string jokePart1; //joke 1st line
string jokePart2; //joke 2nd line
string jokePunch; //joke punch line
//*****Program Statements
void getAJoke(string& jokePart1);
void doJokePart1(string& jokePart2);
void doJokePart2(string& jokePart2);
// display joke punch line
cout << endl << jokePunch << endl;
// display closing message
cout << endl << "Thank you for playing!" << endl;
system("pause");
return 0;
}
void getAJoke(string& jokePart1, string& jokePart2, string& jokePunch)
{
jokePart1 = "knock, knock";
jokePart2 = "little ole lady";
jokePunch = "I didn't know you could yodel!";
}
void doJokePart1(string& jokePart1)
{
string jokeResp1;
cout << jokePart1 << endl;
getline(cin, jokeResp1);
while(jokeResp1 != "who's there?")
{
cout << ("ERROR: " + jokePart1) << endl;
getline(cin, jokeResp1);
}
}
void doJokePart2(string& jokePart2)
{
string jokeResp2;
cout << jokePart2 << endl;
getline(cin, jokeResp2);
while(jokeResp2 != (jokePart2 + " who?") )
{
cout << ("ERROR: " + jokePart2) << endl;
getline(cin, jokeResp2);
}
}
This post has been edited by crackisgood4u: 21 September 2009 - 06:24 AM

New Topic/Question
Reply




MultiQuote








|