i have a better version of this code at home but i am working at college to try and get my program to call the functions listed when needed.
the assignment is nearly finnished as it is quite easy but..... when i call function void exit(); for example, it doesn't create an error, simply ignores it and carry's on as the program would anyway! :S
could someone take a look and see if they can help me out, jus dont change it too much! :P
i have a delay aswell that needs adding but i have all of that typed up at home!
Code:
#include <iostream.h>
// include headers
#include <stdlib.h>
#include <time.h>
// include stdlib header to enable CLS function
char password[5], name[50];
// declare variables of type char
int input, score, ans1, ans2, ans3, ans4, ans5, ans6, ans7, ans8, ans9, ans10, per;
// declare program variables - int
void main();
void table();
void Question1();
void Question2();
void Question3();
void Question4();
void Question5();
void Question6();
void Question7();
void Question8();
void Question9();
void Question10();
void results();
void exit();
void main()
// start of program
{
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Password Protected Program!\n";
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
cout<<"Please enter your Name: ";
cin>>name;
// prompt for Name to be enterd
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Password Protected Program!\n";
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
cout<<"Welcome ";
cout<<name;
cout<<": \n";
cout<<"\nPlease enter the program Password (5 characters): ";
cin>>password;
// prompt for password
if (password[0] == 'm' && password[1] == 'o' && password [2] == 'n' && password[3] == 'k' && password[4] == 'e' && password [5] == 'y')
// check password is correct
{
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n"; // simple 'who logged in' tag
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
// tells user who is logged in
system("CLS");
// Clears and starts program
//////////////////////////////////////////////////////
// MENU BAR HERE /////////////////////////////////////
void table();
{
cout<<"\nPlease Select an option from the menu below:";
cout<<"\n\n1. Start the Test.\n2. Exit";
cout<<"\n\nPlease enter the number you want to select: ";
cin>>input;
if ( input == 1 )
{
void Question1(); // call question one to start
}
else
{
void exit(); // call for function 'exit' to start
}
}
//////////////////////////////////////////////////////
// INTERNAL PROGRAM STARTS HERE //////////////////////
void Question1(); // test questions start here! run question
{
cout<<"\nQuestion 1:\nLive is to evil as 98760 is to: \n";
cout<<"\n1:98067\n2:06789\n3:08967\n4:98760\n\nPlease enter the Number of the required Answer, only one is correct: ";
cin>>ans1;
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
if ( ans1 == 2 )
{
cout<<"!! Correct, next Question: !!\n\n";
score++;
}
else
{
cout<<"!! Incorrect, next Question: !!\n\n";
}
}
void Question2(); // question 2
{
cout<<"\nQuestion 2:\nWhat comes next in the series: 120, 118, 115, 111, 106...: \n";
cout<<"\n1: 105\n2: 85\n3: 100\n4: 98\n\nPlease enter the Number of the required Answer, only one is correct: ";
cin>>ans2;
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
if ( ans2 == 3 )
{
cout<<"!! Correct, next Question: !!\n\n";
score++;
}
else
{
cout<<"!! Incorrect, next Question: !!\n\n";
}
}
void Question3(); // question 3
{
cout<<"\nQuestion 3:\nHand is to Glove as Head is to: \n";
cout<<"\n1: Hat\n2: Hair\n3: Earing\n4: Neck\n\nPlease enter the Number of the required Answer, only one is correct: ";
cin>>ans3;
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
if ( ans3 == 1 )
{
cout<<"!! Correct, next Question: !!\n\n";
score++;
}
else
{
cout<<"!! Incorrect, next Question: !!\n\n";
}
}
void Question4(); // question 4
{
cout<<"\nQuestion 4:\nIf you rearrange the Numbers NAMYERG you would have the name of an: \n";
cout<<"\n1: City\n2: Ocean\n3: State\n4: Country\n\nPlease enter the Number of the required Answer, only one is correct: ";
cin>>ans4;
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
if ( ans4 == 4 )
{
cout<<"!! Correct, next Question: !!\n\n";
score++;
}
else
{
cout<<"!! Incorrect, next Question: !!\n\n";
}
}
void Question5(); // question 5
{
cout<<"\nQuestion 5:\nAnn is taller than Jill, and Kelly is shorter than Ann.\nWhich of the following statements would be most accurate?: \n";
cout<<"\n1: Kelly is taller than Jill\n2: Kelly is shorter than Jill\n3: It's impossible to tell\n4: Kelly is as tall as Jill\n\nPlease enter the Number of the required Answer, only one is correct: ";
cin>>ans5;
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
if ( (ans5) == 3 )
{
cout<<"!! Correct, next Question: !!\n\n";
score++;
}
else
{
cout<<"!! Incorrect, next Question: !!\n\n";
}
}
void Question6(); // question 6
{
cout<<"\nQuestion 6:\nIf some Wicks are Slicks, and some Slicks are Snicks.\nThen some Wicks are definitely Snicks. The statement is: \n";
cout<<"\n1: True\n2: False\n3: Neither\n4: Impossible to tell\n\nPlease enter the Number of the required Answer, only one is correct: ";
cin>>ans6;
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
if ( (ans6) == 1 )
{
cout<<"!! Correct, next Question: !!\n\n";
score++;
}
else
{
cout<<"!! Incorrect, next Question: !!\n\n";
}
}
void Question7(); // question 7
{
cout<<"\nQuestion 7:\nWhat number is one half of one quarter of one tenth of 800?: \n";
cout<<"\n1: 2\n2: 5\n3: 8\n4: 10\n\nPlease enter the Number of the required Answer, only one is correct: ";
cin>>ans7;
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
if ( (ans7) == 4 )
{
cout<<"!! Correct, next Question: !!\n\n";
score++;
}
else
{
cout<<"!! Incorrect, next Question: !!\n\n";
}
}
void Question8(); // question 8
{
cout<<"\nQuestion 8:\nTen people can paint 60 houses in 120 days\nSo five people can paint 30 houses in: \n";
cout<<"\n1: 15 days\n2: 30 days\n3: 60 days\n4: 120 days\n\nPlease enter the Number of the required Answer, only one is correct: ";
cin>>ans8;
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
if ( (ans8) == 4 )
{
cout<<"!! Correct, next Question: !!\n\n";
score++;
}
else
{
cout<<"!! Incorrect, next Question: !!\n\n";
}
}
void Question9(); // question 9
{
cout<<"\nQuestion 9:\nA car traveled 28 miles in 30 minutes. How many miles per hour was it traveling?\n";
cout<<"\n1: 28\n2: 36\n3: 56\n4: 58\n\nPlease enter the Number of the required Answer, only one is correct: ";
cin>>ans9;
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
if ( (ans9) == 3 )
{
cout<<"!! Correct, next Question: !!\n\n";
score++;
}
else
{
cout<<"!! Incorrect, next Question: !!\n\n";
}
}
void Question10(); // question 10
{
cout<<"\nQuestion 10:\nWhat is the chemical symbol for water?: \n";
cout<<"\n1: W\n2: H2O\n3: O2\n4: Liq\n\nPlease enter the Number of the required Answer, only one is correct: ";
cin>>ans10;
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Loged In as: ";
cout<<name;
cout<<"\n+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
if ( (ans10) == 2 )
{
cout<<"Results:\n\n";
score++;
}
else
{
cout<<"Results:\n\n";
}
}
void results(); // start of function 'results' to display how used did in the test
{
system("CLS");
cout<<"Congratulations!\n\nYou have Completed the IQ test!\n\n";
cout<<"Your results are: ";
cout<<score; // output the users score
cout<<" Out Of 10!\n\n"; // out of 10
per=score*10; // calculates the users percentage
cout<<"You got ";
cout<<per;
cout<<" Percent!\n\n"; // tells the user what % they acheived
if (score < 6) // pass or fail?
{
cout<<"!! Sorry, you Falied !!\n\nBetter Luck Next Time!\n\n"; // failed message
}
else
{
cout<<"Well done!\n\nYou Passed!\n\n"; // passed message
}
}
// END OF INTERNAL PROGRAM ///////////////////////////
//////////////////////////////////////////////////////
}
else
{
system("CLS");
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n";
cout<<"Password Protected Program!\n";
cout<<"+*+*+*+*+*+*+*+*+*+*+*+*+*+\n\n";
cout<<"\n!ERROR!\n\n";
cout<<"Incorrect password - please restart program and try again!\n\n";
// tells user they have enterd an incorrect password
system("CLS");
void main(); // calls main function to restart
}
void exit(); // small function to be called when an exit is wanted
{
system("CLS");
cout<<"Thankyou, Goodbye!\n\n";
}
};
// end of program