Program set
-
Hello everyone. Currently, working on a program however i tried my first two programs using a driver but i still have an error. I'm not sure what the issue is. I'm new to c++ any assistance would be appreciated, Attached is the driver and 1 and 2 program. Thanks. Driver:
#include
using std::cout;
using std::cin;
using std::endl;#include
//#include "Miscellaneous.h"void showMenu();
int getResponse();int main()
{int response; //NOTE: each time you finish writing a function and want to test it, //uncomment the case within the switch that calls that function. while ( ( response = getResponse() ) != 5 ) { switch( response ) { //case 1: multiplication(); cout<<"\\n\\n"; break; //case 2: numberGuess(); cout<<"\\n\\n"; break; //case 3: printSquare(); cout<<"\\n\\n"; break; //case 4: calculatePayroll(); cout<<"\\n\\n"; break; } system("pause"); } cout<<"\\n\\nThank you and have a nice day!\\n\\n"; return 0;
}
void showMenu()
{system("cls"); cout<<"\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\\n"; cout<<"\* Press 1 to do multiplication \*\\n"; cout<<"\* Press 2 to play number guessing \*\\n"; cout<<"\* Press 3 to print a square \*\\n"; cout<<"\* Press 4 to calculate payroll \*\\n"; cout<<"\* Press 5 to Quit \*\\n"; cout<<"\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\\n"; cout<<"=====> ";
}
int getResponse()
{
int response;
showMenu();
cin>> response;while( response < 1 || response > 5) { showMenu(); cin >> response; } return response;
}
1 CASE: MULTIPLICATION#include
using std::cout;
using std::endl;
using std::cin;
#include
#include
void correctMessage( void );
void incorrectMessage( void );
void multiplication( void );int main()
{
srand( time( 0 ) );multiplication();
return 0;
}void correctMessage( void )
{
switch ( rand() % 4 ) {
case 0:
cout << "Very good!";break;
case 1:
cout << "Very good!";break;
case 2:
cout << "Very good!";break;
case 3:
cout << "Very good!";break;
}
cout << "\n\n";
}void incorrectMessage( void )
{
switch ( rand() % 4 ) {case 0:
cout << "No. Please try again.";break;
case 1:
cout << "No. Please try again.";break;
case 2:
cout << "No. Please try again!";break;
case 3:
cout << "No. Please try again!";break;
cou -
Hello everyone. Currently, working on a program however i tried my first two programs using a driver but i still have an error. I'm not sure what the issue is. I'm new to c++ any assistance would be appreciated, Attached is the driver and 1 and 2 program. Thanks. Driver:
#include
using std::cout;
using std::cin;
using std::endl;#include
//#include "Miscellaneous.h"void showMenu();
int getResponse();int main()
{int response; //NOTE: each time you finish writing a function and want to test it, //uncomment the case within the switch that calls that function. while ( ( response = getResponse() ) != 5 ) { switch( response ) { //case 1: multiplication(); cout<<"\\n\\n"; break; //case 2: numberGuess(); cout<<"\\n\\n"; break; //case 3: printSquare(); cout<<"\\n\\n"; break; //case 4: calculatePayroll(); cout<<"\\n\\n"; break; } system("pause"); } cout<<"\\n\\nThank you and have a nice day!\\n\\n"; return 0;
}
void showMenu()
{system("cls"); cout<<"\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\\n"; cout<<"\* Press 1 to do multiplication \*\\n"; cout<<"\* Press 2 to play number guessing \*\\n"; cout<<"\* Press 3 to print a square \*\\n"; cout<<"\* Press 4 to calculate payroll \*\\n"; cout<<"\* Press 5 to Quit \*\\n"; cout<<"\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\\n"; cout<<"=====> ";
}
int getResponse()
{
int response;
showMenu();
cin>> response;while( response < 1 || response > 5) { showMenu(); cin >> response; } return response;
}
1 CASE: MULTIPLICATION#include
using std::cout;
using std::endl;
using std::cin;
#include
#include
void correctMessage( void );
void incorrectMessage( void );
void multiplication( void );int main()
{
srand( time( 0 ) );multiplication();
return 0;
}void correctMessage( void )
{
switch ( rand() % 4 ) {
case 0:
cout << "Very good!";break;
case 1:
cout << "Very good!";break;
case 2:
cout << "Very good!";break;
case 3:
cout << "Very good!";break;
}
cout << "\n\n";
}void incorrectMessage( void )
{
switch ( rand() % 4 ) {case 0:
cout << "No. Please try again.";break;
case 1:
cout << "No. Please try again.";break;
case 2:
cout << "No. Please try again!";break;
case 3:
cout << "No. Please try again!";break;
cou -
Hello everyone. Currently, working on a program however i tried my first two programs using a driver but i still have an error. I'm not sure what the issue is. I'm new to c++ any assistance would be appreciated, Attached is the driver and 1 and 2 program. Thanks. Driver:
#include
using std::cout;
using std::cin;
using std::endl;#include
//#include "Miscellaneous.h"void showMenu();
int getResponse();int main()
{int response; //NOTE: each time you finish writing a function and want to test it, //uncomment the case within the switch that calls that function. while ( ( response = getResponse() ) != 5 ) { switch( response ) { //case 1: multiplication(); cout<<"\\n\\n"; break; //case 2: numberGuess(); cout<<"\\n\\n"; break; //case 3: printSquare(); cout<<"\\n\\n"; break; //case 4: calculatePayroll(); cout<<"\\n\\n"; break; } system("pause"); } cout<<"\\n\\nThank you and have a nice day!\\n\\n"; return 0;
}
void showMenu()
{system("cls"); cout<<"\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\\n"; cout<<"\* Press 1 to do multiplication \*\\n"; cout<<"\* Press 2 to play number guessing \*\\n"; cout<<"\* Press 3 to print a square \*\\n"; cout<<"\* Press 4 to calculate payroll \*\\n"; cout<<"\* Press 5 to Quit \*\\n"; cout<<"\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\\n"; cout<<"=====> ";
}
int getResponse()
{
int response;
showMenu();
cin>> response;while( response < 1 || response > 5) { showMenu(); cin >> response; } return response;
}
1 CASE: MULTIPLICATION#include
using std::cout;
using std::endl;
using std::cin;
#include
#include
void correctMessage( void );
void incorrectMessage( void );
void multiplication( void );int main()
{
srand( time( 0 ) );multiplication();
return 0;
}void correctMessage( void )
{
switch ( rand() % 4 ) {
case 0:
cout << "Very good!";break;
case 1:
cout << "Very good!";break;
case 2:
cout << "Very good!";break;
case 3:
cout << "Very good!";break;
}
cout << "\n\n";
}void incorrectMessage( void )
{
switch ( rand() % 4 ) {case 0:
cout << "No. Please try again.";break;
case 1:
cout << "No. Please try again.";break;
case 2:
cout << "No. Please try again!";break;
case 3:
cout << "No. Please try again!";break;
couI've fixed you program for you, in order to perform correctly the multiplication case. All the other ones are up to you.
#include using std::cout;
using std::cin;
using std::endl;#include
#include void showMenu();
int getResponse();void correctMessage( );
void incorrectMessage( );
void multiplication( );int main()
{
int response;//NOTE: each time you finish writing a function and want to test it,
//uncomment the case within the switch that calls that function.
while ( ( response = getResponse() ) != 5 )
{
switch( response )
{
case 1:
multiplication(); cout<<"\n\n";
break;
//case 2: numberGuess(); cout<<"\n\n"; break;
//case 3: printSquare(); cout<<"\n\n"; break;
//case 4: calculatePayroll(); cout<<"\n\n"; break;
default:
if ( response < 5)
cout << "sorry, not yet implemented\n\n";
break;
}
}
cout<<"\n\nThank you and have a nice day!\n\n";
return 0;
}void showMenu()
{
system("cls");
cout<<"***********************************\n";
cout<<"* Press 1 to do multiplication *\n";
cout<<"* Press 2 to play number guessing *\n";
cout<<"* Press 3 to print a square *\n";
cout<<"* Press 4 to calculate payroll *\n";
cout<<"* Press 5 to Quit *\n";
cout<<"***********************************\n";
cout<<"=====> ";
}int getResponse()
{
int response;
showMenu();
cin>> response;while( response < 1 || response > 5)
{
showMenu();
cin >> response;
}
return response;
}void correctMessage( void )
{
cout << "Very good!\n";
}void incorrectMessage( void )
{
cout << "No. Please try again.\n";
}void multiplication( void )
{
int x, y, response = 0;
srand( time( 0 ) );while ( response != -1 )
{
x = rand() % 10;
y = rand() % 10;
cout << "How much is " << x << " times " << y<< " (-1 to End)? "; cin >> response;
while ( response != -1 && response != x * y )
{
incorrectMessage();
cin >> response;
}
if ( response != -1 )
{
correctMessage();
}
}
}"In testa che avete, Signor di Ceprano?" -- Rigoletto