Classes for a Quiz Program

im a beginner and the program should have 3 classes but i cant make it

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 1900 Views - Last Post: 23 August 2009 - 07:12 AM Rate Topic: -----

#1 cziel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 22-August 09

Classes for a Quiz Program

Post icon  Posted 22 August 2009 - 08:41 PM

this program should have 3 classes but i cant convert my codes to that with some class form..pls help me..
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;


		
void main()
{


	FILE *group7a;
	FILE *group7b;
	FILE *group7c;
	char aaa[40];
	char bbb[40];
	char ccc[40];
	char user[10];
	char pass[10];
	int file1=1;
	int file2=2;
	int file3=3;
	


	int easyx=0;
	int easyy=0;
	int avex=0;
	int avey=0;
	int hardx=0;
	int hardy=0;
	int hamp;
	char hatch;
	char z1=0;
	char z2=0;
	char z3=0;
	char z4=0;
	char z5=0;
	char z6=0;
	char z7=0;
	char z8=0;
	char z9=0;
	char z10=0;
	char y1=0;
	char y2=0;
	char y3=0;
	char y4=0;
	char y5=0;
	char y6=0;
	char y7=0;
	char y8=0;
	char y9=0;
	char y10=0;
	char x1=0;
	char x2=0;
	char x3=0;
	char x4=0;
	char x5=0;
	char x6=0;
	char x7=0;
	char x8=0;
	char x9=0;
	char x10=0;
		  hatch='n';
		while(hatch!='y')
		{

		
		cout<<"Input username to continue:"<<endl;
		cin>>user;
		cout<<"Input password:"<<endl;
		
		cin>>pass;
		if((strcmp(user,"lasalle")==0)&&(strcmp(pass,"group7")==0))
		{
		cout<<"\nCORRECT USERNAME AND PASSWORD!\n"<<endl;
		void password();
		}else{
			cout<<"\nWRONG USERNAME AND PASSWORD. ACCESS IS DENIED\n"<<endl;
			exit(0);
	
		}		

void password();
	
	cout<<"SCIENCE IS FUN GAME"<<endl;
	cout<<"Main Menu"<<endl;
	cout<<"1 - Game Description"<<endl;
	cout<<"2 - Game Programmers"<<endl;
	cout<<"3 - EASY ROUND"<<endl;
	cout<<"4 - AVERAGE ROUND"<<endl;
	cout<<"5 - DIFFICULT ROUND"<<endl;
	cout<<"6 - Exit"<<endl;
	cout<<"Choose "<<endl;
	cin>>hamp;
	
	
	switch(hamp)
	{
	case 1:
		{
			cout<<"PROGRAM DESCRIPTION: "<<endl;
			cout<<"\n\n\n\n\n\n\n\n"<<endl;
			cout<<"IT "<<endl;
			cout<<"Presented for "<<endl;
			cout<<"The Partial Fullfillment"<<endl;
			cout<<"In the course of"<<endl;
			cout<<"Object Oriented Programming"<<endl;
			cout<<"Presented to:"<<endl;
			cout<<"Mr."<<endl;
			cout<<"Presented by the:"<<endl;
			cout<<"GROUP "<<endl;
			cout<<"July 30, 2009"<<endl;
			
			cout<<"^_^/>"<<endl;
			cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
			cout<<"THANK YOU!\n\n\n\n\n";
			
	
		break;

		}
	case 2:
		{
			cout<<"THE PROGRAMMERS:"<<endl;
			cout<<"GCP.T"<<endl;
			cout<<"WC.B"<<endl;
			cout<<"OD"<<endl;
cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
			cout<<"THANK YOU!\n\n\n\n\n";
		
			break;

		}
	case 3:
		{
			cout<<"EASY ROUND:"<<endl;
			cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
			cout<<"\n\n\n\nEasy round is all about GENERAL SCIENCE.\n\n\n\n";
			cout<<"1.What is the first element in the periodic table of element?"<<endl;
			cout<<"a. helium"<<endl;
			cout<<"b. mercury"<<endl;
			cout<<"c. hydrogen"<<endl;
			cout<<"d. oxygen"<<endl;
				cin>>z1;
				
			if(z1=='c')
			{
				easyx=easyx+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				easyy=easyy+1;
				cout<<"SORRY! YOU ARE WRONG. THE CORRECT ANSWER IS: C\a "<<endl;
			}
			cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"2. What is the study of various species of life?"<<endl;
			cout<<"a. chemistry"<<endl;
			cout<<"b. biology"<<endl;
			cout<<"c. physics"<<endl;
			cout<<"d. physical science"<<endl;
			cin>>z2;	
			if(z2=='b')
		{
				easyx=easyx+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				easyy=easyy+1;
cout<<"SORRY! YOU ARE WRONG. THE CORRECT ANSWER IS: B\a "<<endl;
			}
			cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"3. Who discovered the telephone?"<<endl;
			cout<<"a. Thomas Edison"<<endl;
			cout<<"b. Albert Einstein"<<endl;
			cout<<"c. Galileo Galilei"<<endl;
			cout<<"d. Jimmy Neutron"<<endl;
			cin>>z3;
	
			if(z3=='a')
		{
				easyx=easyx+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				easyy=easyy+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
			}
		cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"4. What is the biggest planet in the solar system?"<<endl;
			cout<<"a. Mars"<<endl;
			cout<<"b. Jupiter"<<endl;
			cout<<"c. Saturn"<<endl;
			cout<<"d. Vesta"<<endl;
			cin>>z4;
	
			if(z4=='b')
		{
				easyx=easyx+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				easyy=easyy+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
			}
			cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"5. What is the basic unit of life?"<<endl;
			cout<<"a. blood"<<endl;
			cout<<"b. heart"<<endl;
			cout<<"c. brain"<<endl;
			cout<<"d. cell"<<endl;
			cin>>z5;

	if(z5=='d')
		{
				easyx=easyx+1;
			cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				easyy=easyy+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: D \a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"6. Who is the father of biology?"<<endl;
			cout<<"a. Socrates"<<endl;
			cout<<"b. Aristotle"<<endl;
			cout<<"c. Plato"<<endl;
			cout<<"d. none of the above"<<endl;
			cin>>z6;

			if(z6=='b')
			{
				easyx=easyx+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				easyy=easyy+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"7. What is the smallest planet in the solar system?"<<endl;
			cout<<"a. Pluto"<<endl;
			cout<<"b. Mercury"<<endl;
			cout<<"c. Mars"<<endl;
			cout<<"d. Ceres"<<endl;
			cin>>z7;

			if(z7=='b')
			{
				easyx=easyx+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				easyy=easyy+1;
				cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"8. Astronomy is under what field of science?"<<endl;
			cout<<"a. physics"<<endl;
			cout<<"b. chemistry"<<endl;
			cout<<"c. biology"<<endl;
			cout<<"d. none of the above"<<endl;
			cin>>z8;

			if(z8=='d')
			{
				easyx=easyx+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				easyy=easyy+1;
				cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: D\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"9. Who is the cartoon character also known as BOY - GENIUS?"<<endl;
			cout<<"a. Ash Ketchum"<<endl;
			cout<<"b. Spongebob Squarepants"<<endl;
			cout<<"c. Jimmy Neutron"<<endl;
			cout<<"d. Astroboy"<<endl;
				cin>>z9;
			if(z9=='c')
			{
				easyx=easyx+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				easyy=easyy+1;
				cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"10. What is the highest level of mankind here in earth?"<<endl;
			cout<<"a. humans"<<endl;
			cout<<"b. animals"<<endl;
				cout<<"c. microbes"<<endl;
				cout<<"d. none of the above"<<endl;
				cin>>z10;
				if(z10=='a')
				{
					easyx=easyx+1;
					cout<<"YOUR ANSWER IS CORRECT!"<<endl;
				}else{
					easyy=easyy+1;
					cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
				}




			cout<<"^_^/>"<<endl;
cout<<"You have "<<easyx<<" correct answers."<<endl;
			cout<<"You have "<<easyy<<" wrong answers."<<endl;
			cout<<"Print your score. "<<endl;
			cout<<"Input name of output text file: "<<endl;
			cin>>aaa;
			group7a=fopen(aaa,"w");
			fprintf(group7a,"EASY ROUND	  %d\n",file1);
			fprintf(group7a,"Correct answers = %d\n",easyx);
				fprintf(group7a,"Wrong answers = %d\n",easyy);
			fclose(group7a);
	
			
		cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAMER AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
			cout<<"THANK YOU!\n\n\n\n\n";
		


			break;

		}
	case 4:
		{
			cout<<"Average Round"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
			cout<<"\n\n\n\nAVERAGE ROUND IS ALL ABOUT PHYSICAL SCIENCE.\n\n\n\n";
			cout<<"1.What is the first man-made satelite?"<<endl;
			cout<<"a. sputnik1"<<endl;
			cout<<"b. sputnik3"<<endl;
			cout<<"c. apollo1"<<endl;
			cout<<"d. apollo11"<<endl;
				cin>>y1;
			if(y1=='a')
			{
				avex=avex+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				avey=avey+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
			}
			cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"2.What makes Uranus blue?"<<endl;
			cout<<"a. carbon dioxide"<<endl;
			cout<<"b. helium"<<endl;
			cout<<"c. methane"<<endl;
			cout<<"d. hydrogen"<<endl;
				cin>>y2;
			if(y2=='c')
			{
				avex=avex+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				avey=avey+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"3.What is the largest asteroid?"<<endl;
			cout<<"a. eris"<<endl;
			cout<<"b. ceres"<<endl;
			cout<<"c. pluto"<<endl;
			cout<<"d. comets"<<endl;
				cin>>y3;
			if(y3=='b')
			{
				avex=avex+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				avey=avey+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"4.What is the largest mountain in the solar system?"<<endl;
			cout<<"a. mt.apo"<<endl;
			cout<<"b. mt.everest"<<endl;
			cout<<"c. olympus wind"<<endl;
			cout<<"d. olympus mons"<<endl;
				cin>>y4;
			if(y4=='d')
			{
				avex=avex+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				avey=avey+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: D\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"5.What makes mars red?"<<endl;
			cout<<"a. helium"<<endl;
			cout<<"b. iron oxide"<<endl;
			cout<<"c. hydrogen"<<endl;
			cout<<"d. methane"<<endl;
				cin>>y5;
			if(y5=='b')
			{
				avex=avex+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				avey=avey+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"6.What is the hottest planet in the solar system?"<<endl;
			cout<<"a. mercury"<<endl;
			cout<<"b. jupiter"<<endl;
			cout<<"c. venus"<<endl;
			cout<<"d. earth"<<endl;
				cin>>y6;
			if(y6=='c')
			{
				avex=avex+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				avey=avey+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"7.What is the nearest point of a planet to the sun?"<<endl;
			cout<<"a. perihelion"<<endl;
			cout<<"b. aphelion"<<endl;
			cout<<"c. perigee"<<endl;
			cout<<"d. apogee"<<endl;
				cin>>y7;
			if(y7=='a')
			{
				avex=avex+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				avey=avey+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"8. When did the first manned moon landing happen?"<<endl;
			cout<<"a. May 6, 1969"<<endl;
			cout<<"b. July 16, 1908"<<endl;
			cout<<"c. July 21, 1969"<<endl;
			cout<<"d. none of the above"<<endl;
			cin>>y8;
			if(y8=='c')
			{
				avex=avex+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				avey=avey+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"9. What is the biggest moon of Jupiter?"<<endl;
			cout<<"a. Ganymede"<<endl;
			cout<<"b. Callisto"<<endl;
			cout<<"c. Io"<<endl;
			cout<<"d. Europa"<<endl;
			cin>>y9;
			if(y9=='a')
			{
				avex=avex+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				avey=avey+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"10. What were the first creatures in this world to fly?"<<endl;
			cout<<"a. birds"<<endl;
			cout<<"b. insects"<<endl;
			cout<<"c. butterflies"<<endl;
			cout<<"d. none of the above"<<endl;
			cin>>y10;
			if(y10=='b')
			{
				avex=avex+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
			}else{
				avey=avey+1;
				cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
			}

cout<<"^_^/>"<<endl;
cout<<"You have "<<avex<<" correct answers."<<endl;
			cout<<"You have "<<avey<<" wrong answers."<<endl;
			cout<<"Print your score. "<<endl;
			cout<<"Input name of output text file: "<<endl;
			cin>>bbb;
			group7b=fopen(bbb,"w");
			fprintf(group7b,"AVERAGE ROUND	  %d\n",file2);
			fprintf(group7b,"Correct answers = %d\n",avex);
				fprintf(group7b,"Wrong answers = %d\n",avey);
			fclose(group7b);

cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
			cout<<"THANK YOU!\n\n\n\n\n";

			
			break;

		}
	case 5:
		{
			cout<<"DIFFICULT ROUND"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
			cout<<"\n\n\n\nDIFFICULT ROUND IS ALL ABOUT SCIENTIFIC NAMES\n\n\n\n";
			cout<<"1. What is the scientific name of bat?"<<endl;
			cout<<"a. Order Chiroptera"<<endl;
			cout<<"b. Order Cetacea"<<endl;
			cout<<"c. Order Carnivora"<<endl;
			cout<<"d. Order Casanova"<<endl;
			cin>>x1;
			if(x1=='a')
			{
			hardx=hardx+1;
			cout<<"YOUR ANSWER IS CORRECT!"<<endl;
		}else{
			hardy=hardy+1;
			cout<<"IT'S WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
		}
cout<<"\n\n\n\n\n\n\n\n\n\n";
		cout<<"2. What is the scientific name of blue whale?"<<endl;
		cout<<"a. Balaeniceps rex"<<endl;
		cout<<"b. Balaenoptera musculus"<<endl;
		cout<<"c. Branta canadensis"<<endl;
		cout<<"d. Bufo bufo"<<endl;
		cin>>x2;
		if(x2=='b')
		{
			hardx=hardx+1;
		cout<<"YOUR ANSWER IS CORRECT!"<<endl;
		}else{
			hardy=hardy+1;
			cout<<"IT'S WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
			}
cout<<"\n\n\n\n\n\n\n\n\n\n";
			cout<<"3. What is the scientific name of Western Gull?"<<endl;
			cout<<"a. Larus occidentalis"<<endl;
			cout<<"b. Egretta thula"<<endl;
			cout<<"c. Larus argentatus"<<endl;
			cout<<"d. Pitecopaga jefferyi"<<endl;
			cin>>x3;
			if(x3=='a')
			{
			hardx=hardx+1;
			cout<<"YOUR ANSWER IS CORRECT!"<<endl;

			}else{
				hardy=hardy+1;
				cout<<"IT'S WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
				}
cout<<"\n\n\n\n\n\n\n\n\n\n";
				cout<<"4. What is the scientific name of lion?"<<endl;
				cout<<"a. Panthera leo"<<endl;
				cout<<"b. Merlion leo"<<endl;
				cout<<"c. Cannis Vulpes"<<endl;
				cout<<"d. Larus Canus"<<endl;
				cin>>x4;
				if(x4=='a')
				{
					hardx=hardx+1;
				cout<<"YOUR ANSWER IS CORRECT!"<<endl;
				}else{
					hardy=hardy+1;
					cout<<"IT'S WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
				}
cout<<"\n\n\n\n\n\n\n\n\n\n";
				cout<<"5. What is the scientific name of peacock?"<<endl;
				cout<<"a. Falcon Falco"<<endl;
				cout<<"b. Gruidae Gruiformes"<<endl;
				cout<<"c. Arboreal Ateles "<<endl;
				cout<<"d. Pava Cristatus "<<endl;
				cin>>x5;
				if(x5=='d')
				{
					hardx=hardx+1;
					cout<<"YOUR ANSWER IS CORRECT!"<<endl;
				}else{
					hardy=hardy+1;
					cout<<"IT'S WRONG. THE CORRECT ANSWER IS: D\a"<<endl;
				}
cout<<"\n\n\n\n\n\n\n\n\n\n";
				cout<<"6. What is the scientific name of pig?"<<endl;
				cout<<"a. Artiodactyla Suidae"<<endl;
				cout<<"b. Equs Asinus"<<endl;
				cout<<"c. Rangifer Tarrandus "<<endl;
				cout<<"d. Perrissodanctyl Rthinocerotidae"<<endl;
				cin>>x6;
				if(x6=='a')
				{
					hardx=hardx+1;
					cout<<"YOUR ANSWER IS CORRECT!"<<endl;
				}else{
					hardy=hardy+1;
					cout<<"IT'S WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
				}
cout<<"\n\n\n\n\n\n\n\n\n\n";
				cout<<"7. What is the scientific name of mouse?"<<endl;
				cout<<"a. Edwinde Dangson"<<endl;
				cout<<"b. Rodentia Muridae"<<endl;
				cout<<"c. Rangifer Tarrandus"<<endl;
				cout<<"d. Acinonyx Jubatus "<<endl;
				cin>>x7;
				if(x7=='b')
				{
					hardx=hardx+1;
					cout<<"YOUR ANSWER IS CORRECT!"<<endl;
				}else{
					hardy=hardy+1;
					cout<<"IT'S WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
				}
cout<<"\n\n\n\n\n\n\n\n\n\n";
				cout<<"8. What is the scientific name of tiger?"<<endl;
				cout<<&#



This post has been edited by cziel: 23 August 2009 - 04:42 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Classes for a Quiz Program

#2 Elcric  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 101
  • View blog
  • Posts: 453
  • Joined: 02-May 09

Re: Classes for a Quiz Program

Posted 22 August 2009 - 09:05 PM

Hello, :D

What is your question?

[code]
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;



//************************************
// MAIN() FUNCTION.
//************************************
int main(int argc, char* argv[])
{


FILE *group7a;
FILE *group7b;
FILE *group7c;
char aaa[40];
char bbb[40];
char ccc[40];
char user[10];
char pass[10];
int file1=1;
int file2=2;
int file3=3;



int easyx=0;
int easyy=0;
int avex=0;
int avey=0;
int hardx=0;
int hardy=0;
int hamp;
char hatch;
char z1=0;
char z2=0;
char z3=0;
char z4=0;
char z5=0;
char z6=0;
char z7=0;
char z8=0;
char z9=0;
char z10=0;
char y1=0;
char y2=0;
char y3=0;
char y4=0;
char y5=0;
char y6=0;
char y7=0;
char y8=0;
char y9=0;
char y10=0;
char x1=0;
char x2=0;
char x3=0;
char x4=0;
char x5=0;
char x6=0;
char x7=0;
char x8=0;
char x9=0;
char x10=0;
hatch='n';
while(hatch!='y')
{


cout<<"Input username to continue:"<<endl;
cin>>user;
cout<<"Input password:"<<endl;

cin>>pass;
if((strcmp(user,"lasalle")==0)&&(strcmp(pass,"group7")==0))
{
cout<<"\nCORRECT USERNAME AND PASSWORD!\n"<<endl;
void password();
}else{
cout<<"\nWRONG USERNAME AND PASSWORD. ACCESS IS DENIED\n"<<endl;
exit(0);

}

void password();

cout<<"SCIENCE IS FUN GAME"<<endl;
cout<<"Main Menu"<<endl;
cout<<"1 - Game Description"<<endl;
cout<<"2 - Game Programmers"<<endl;
cout<<"3 - EASY ROUND"<<endl;
cout<<"4 - AVERAGE ROUND"<<endl;
cout<<"5 - DIFFICULT ROUND"<<endl;
cout<<"6 - Exit"<<endl;
cout<<"Choose "<<endl;
cin>>hamp;


switch(hamp)
{
case 1:
{
cout<<"PROGRAM DESCRIPTION: "<<endl;
cout<<"\n\n\n\n\n\n\n\n"<<endl;
cout<<"IT Project2"<<endl;
cout<<"Presented for "<<endl;
cout<<"The Partial Fullfillment"<<endl;
cout<<"In the course of"<<endl;
cout<<"Object Oriented Programming"<<endl;
cout<<"Presented to:"<<endl;
cout<<"Mr. Mark G. De Vera"<<endl;
cout<<"Presented by the:"<<endl;
cout<<"GROUP 7"<<endl;
cout<<"July 30, 2009"<<endl;

cout<<"^_^"<<endl;
cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";


break;

}
case 2:
{
cout<<"THE PROGRAMMERS:"<<endl;
cout<<"Gian Carlo P. Torres"<<endl;
cout<<"Wendel C. Balita"<<endl;
cout<<"Oscar Dimaculangan"<<endl;
cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";

break;

}
case 3:
{
cout<<"EASY ROUND:"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
cout<<"\n\n\n\nEasy round is all about GENERAL SCIENCE.\n\n\n\n";
cout<<"1.What is the first element in the periodic table of element?"<<endl;
cout<<"a. helium"<<endl;
cout<<"b. mercury"<<endl;
cout<<"c. hydrogen"<<endl;
cout<<"d. oxygen"<<endl;
cin>>z1;

if(z1=='c')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY! YOU ARE WRONG. THE CORRECT ANSWER IS: C\a "<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"2. What is the study of various species of life?"<<endl;
cout<<"a. chemistry"<<endl;
cout<<"b. biology"<<endl;
cout<<"c. physics"<<endl;
cout<<"d. physical science"<<endl;
cin>>z2;
if(z2=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY! YOU ARE WRONG. THE CORRECT ANSWER IS: B\a "<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"3. Who discovered the telephone?"<<endl;
cout<<"a. Thomas Edison"<<endl;
cout<<"b. Albert Einstein"<<endl;
cout<<"c. Galileo Galilei"<<endl;
cout<<"d. Jimmy Neutron"<<endl;
cin>>z3;

if(z3=='a')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"4. What is the biggest planet in the solar system?"<<endl;
cout<<"a. Mars"<<endl;
cout<<"b. Jupiter"<<endl;
cout<<"c. Saturn"<<endl;
cout<<"d. Vesta"<<endl;
cin>>z4;

if(z4=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"5. What is the basic unit of life?"<<endl;
cout<<"a. blood"<<endl;
cout<<"b. heart"<<endl;
cout<<"c. brain"<<endl;
cout<<"d. cell"<<endl;
cin>>z5;

if(z5=='d')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: D \a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"6. Who is the father of biology?"<<endl;
cout<<"a. Socrates"<<endl;
cout<<"b. Aristotle"<<endl;
cout<<"c. Plato"<<endl;
cout<<"d. none of the above"<<endl;
cin>>z6;

if(z6=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"7. What is the smallest planet in the solar system?"<<endl;
cout<<"a. Pluto"<<endl;
cout<<"b. Mercury"<<endl;
cout<<"c. Mars"<<endl;
cout<<"d. Ceres"<<endl;
cin>>z7;

if(z7=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"8. Astronomy is under what field of science?"<<endl;
cout<<"a. physics"<<endl;
cout<<"b. chemistry"<<endl;
cout<<"c. biology"<<endl;
cout<<"d. none of the above"<<endl;
cin>>z8;

if(z8=='d')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: D\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"9. Who is the cartoon character also known as BOY - GENIUS?"<<endl;
cout<<"a. Ash Ketchum"<<endl;
cout<<"b. Spongebob Squarepants"<<endl;
cout<<"c. Jimmy Neutron"<<endl;
cout<<"d. Astroboy"<<endl;
cin>>z9;
if(z9=='c')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"10. What is the highest level of mankind here in earth?"<<endl;
cout<<"a. humans"<<endl;
cout<<"b. animals"<<endl;
cout<<"c. microbes"<<endl;
cout<<"d. none of the above"<<endl;
cin>>z10;
if(z10=='a')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}




cout<<"^_^"<<endl;
cout<<"You have "<<easyx<<" correct answers."<<endl;
cout<<"You have "<<easyy<<" wrong answers."<<endl;
cout<<"Print your score. "<<endl;
cout<<"Input name of output text file: "<<endl;
cin>>aaa;
group7a=fopen(aaa,"w");
fprintf(group7a,"EASY ROUND %d\n",file1);
fprintf(group7a,"Correct answers = %d\n",easyx);
fprintf(group7a,"Wrong answers = %d\n",easyy);
fclose(group7a);


cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAMER AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";



break;

}
case 4:
{
cout<<"Average Round"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
cout<<"\n\n\n\nAVERAGE ROUND IS ALL ABOUT PHYSICAL SCIENCE.\n\n\n\n";
cout<<"1.What is the first man-made satelite?"<<endl;
cout<<"a. sputnik1"<<endl;
cout<<"b. sputnik3"<<endl;
cout<<"c. apollo1"<<endl;
cout<<"d. apollo11"<<endl;
cin>>y1;
if(y1=='a')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"2.What makes Uranus blue?"<<endl;
cout<<"a. carbon dioxide"<<endl;
cout<<"b. helium"<<endl;
cout<<"c. methane"<<endl;
cout<<"d. hydrogen"<<endl;
cin>>y2;
if(y2=='c')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"3.What is the largest asteroid?"<<endl;
cout<<"a. eris"<<endl;
cout<<"b. ceres"<<endl;
cout<<"c. pluto"<<endl;
cout<<"d. comets"<<endl;
cin>>y3;
if(y3=='b')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"4.What is the largest mountain in the solar system?"<<endl;
cout<<"a. mt.apo"<<endl;
cout<<"b. mt.everest"<<endl;
cout<<"c. olympus wind"<<endl;
cout<<"d. olympus mons"<<endl;
cin>>y4;
if(y4=='d')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: D\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"5.What makes mars red?"<<endl;
cout<<"a. helium"<<endl;
cout<<"b. iron oxide"<<endl;
cout<<"c. hydrogen"<<endl;
cout<<"d. methane"<<endl;
cin>>y5;
if(y5=='b')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"6.What is the hottest planet in the solar system?"<<endl;
cout<<"a. mercury"<<endl;
cout<<"b. jupiter"<<endl;
cout<<"c. venus"<<endl;
cout<<"d. earth"<<endl;
cin>>y6;
if(y6=='c')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"7.What is the nearest point of a planet to the sun?"<<endl;
cout<<"a. perihelion"<<endl;
cout<<"b. aphelion"<<endl;
cout<<"c. perigee"<<endl;
cout<<"d. apogee"<<endl;
cin>>y7;
if(y7=='a')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"8. When did the first manned moon landing happen?"<<endl;
cout<<"a. May 6, 1969"<<endl;
cout<<"b. July 16, 1908"<<endl;
cout<<"c. July 21, 1969"<<endl;
cout<<"d. none of the above"<<endl;
cin>>y8;
if(y8=='c')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"9. What is the biggest moon of Jupiter?"<<endl;
cout<<"a. Ganymede"<<endl;
cout<<"b. Callisto"<<endl;
cout<<"c. Io"<<endl;
cout<<"d. Europa"<<endl;
cin>>y9;
if(y9=='a')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"10. What were the first creatures in this world to fly?"<<endl;
cout<<"a. birds"<<endl;
cout<<"b. insects"<<endl;
cout<<"c. butterflies"<<endl;
cout<<"d. none of the above"<<endl;
cin>>y10;
if(y10=='b')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}

cout<<"^_^"<<endl;
cout<<"You have "<<avex<<" correct answers."<<endl;
cout<<"You have "<<avey<<" wrong answers."<<endl;
cout<<"Print your score. "<<endl;
cout<<"Input name of output text file: "<<endl;
cin>>bbb;
group7b=fopen(bbb,"w");
fprintf(group7b,"AVERAGE ROUND %d\n",file2);
fprintf(group7b,"Correct answers = %d\n",avex);
fprintf(group7b,"Wrong answers = %d\n",avey);
fclose(group7b);

cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";


break;

}
case 5:
{
cout<<"DIFFICULT ROUND"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
cout<<"\n\n\n\nDIFFICULT ROUND IS ALL ABOUT SCIENTIFIC NAMES\n\n\n\n";
cout<<"1. What is the scientific name of bat?"<<endl;
cout<<"a. Order Chiroptera"<<endl;
cout<<"b. Order Cetacea"<<endl;
cout<<"c. Order Carnivora"<<endl;
cout<<"d. Order Casanova"<<endl;
cin>>x1;
if(x1=='a')
{
hardx=hardx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
hardy=hardy+1;
cout<<"IT'S WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"2. What is the scientific name of blue whale?"<<endl;
cout<<"a. Balaeniceps rex"<<endl;
cout<<"b. Balaenoptera musculus"<<endl;
cout<<"c. Branta canadensis"<<endl;
cout<<"d. Bufo bufo"<<endl;
cin>>x2;
if(x2=='b')
{
hardx=hardx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
hardy=hardy+1;
cout<<"IT'S WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
 &n
Was This Post Helpful? 0
  • +
  • -

#3 cziel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 22-August 09

Re: Classes for a Quiz Program

Posted 22 August 2009 - 09:12 PM

uhmmm thanks for replying in my post

you see, the program should contain three or more classes in it..
but my codes doesn't have any classes,,i have trouble converting my codes to have classes in it...
Was This Post Helpful? 0
  • +
  • -

#4 Elcric  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 101
  • View blog
  • Posts: 453
  • Joined: 02-May 09

Re: Classes for a Quiz Program

Posted 22 August 2009 - 09:35 PM

Hello,

I did not see it at the top of your post, sorry.

[code]
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;



//************************************
// MAIN() FUNCTION.
//************************************
int main(int argc, char* argv[])
{


FILE *group7a;
FILE *group7b;
FILE *group7c;
char aaa[40];
char bbb[40];
char ccc[40];
char user[10];
char pass[10];
int file1=1;
int file2=2;
int file3=3;



int easyx=0;
int easyy=0;
int avex=0;
int avey=0;
int hardx=0;
int hardy=0;
int hamp;
char hatch;
char z1=0;
char z2=0;
char z3=0;
char z4=0;
char z5=0;
char z6=0;
char z7=0;
char z8=0;
char z9=0;
char z10=0;
char y1=0;
char y2=0;
char y3=0;
char y4=0;
char y5=0;
char y6=0;
char y7=0;
char y8=0;
char y9=0;
char y10=0;
char x1=0;
char x2=0;
char x3=0;
char x4=0;
char x5=0;
char x6=0;
char x7=0;
char x8=0;
char x9=0;
char x10=0;
hatch='n';
while(hatch!='y')
{


cout<<"Input username to continue:"<<endl;
cin>>user;
cout<<"Input password:"<<endl;

cin>>pass;
if((strcmp(user,"lasalle")==0)&&(strcmp(pass,"group7")==0))
{
cout<<"\nCORRECT USERNAME AND PASSWORD!\n"<<endl;
void password();
}else{
cout<<"\nWRONG USERNAME AND PASSWORD. ACCESS IS DENIED\n"<<endl;
exit(0);

}

void password();

cout<<"SCIENCE IS FUN GAME"<<endl;
cout<<"Main Menu"<<endl;
cout<<"1 - Game Description"<<endl;
cout<<"2 - Game Programmers"<<endl;
cout<<"3 - EASY ROUND"<<endl;
cout<<"4 - AVERAGE ROUND"<<endl;
cout<<"5 - DIFFICULT ROUND"<<endl;
cout<<"6 - Exit"<<endl;
cout<<"Choose "<<endl;
cin>>hamp;


switch(hamp)
{
case 1:
{
cout<<"PROGRAM DESCRIPTION: "<<endl;
cout<<"\n\n\n\n\n\n\n\n"<<endl;
cout<<"IT Project2"<<endl;
cout<<"Presented for "<<endl;
cout<<"The Partial Fullfillment"<<endl;
cout<<"In the course of"<<endl;
cout<<"Object Oriented Programming"<<endl;
cout<<"Presented to:"<<endl;
cout<<"Mr. Mark G. De Vera"<<endl;
cout<<"Presented by the:"<<endl;
cout<<"GROUP 7"<<endl;
cout<<"July 30, 2009"<<endl;

cout<<"^_^"<<endl;
cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";


break;

}
case 2:
{
cout<<"THE PROGRAMMERS:"<<endl;
cout<<"Gian Carlo P. Torres"<<endl;
cout<<"Wendel C. Balita"<<endl;
cout<<"Oscar Dimaculangan"<<endl;
cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";

break;

}
case 3:
{
cout<<"EASY ROUND:"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
cout<<"\n\n\n\nEasy round is all about GENERAL SCIENCE.\n\n\n\n";
cout<<"1.What is the first element in the periodic table of element?"<<endl;
cout<<"a. helium"<<endl;
cout<<"b. mercury"<<endl;
cout<<"c. hydrogen"<<endl;
cout<<"d. oxygen"<<endl;
cin>>z1;

if(z1=='c')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY! YOU ARE WRONG. THE CORRECT ANSWER IS: C\a "<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"2. What is the study of various species of life?"<<endl;
cout<<"a. chemistry"<<endl;
cout<<"b. biology"<<endl;
cout<<"c. physics"<<endl;
cout<<"d. physical science"<<endl;
cin>>z2;
if(z2=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY! YOU ARE WRONG. THE CORRECT ANSWER IS: B\a "<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"3. Who discovered the telephone?"<<endl;
cout<<"a. Thomas Edison"<<endl;
cout<<"b. Albert Einstein"<<endl;
cout<<"c. Galileo Galilei"<<endl;
cout<<"d. Jimmy Neutron"<<endl;
cin>>z3;

if(z3=='a')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"4. What is the biggest planet in the solar system?"<<endl;
cout<<"a. Mars"<<endl;
cout<<"b. Jupiter"<<endl;
cout<<"c. Saturn"<<endl;
cout<<"d. Vesta"<<endl;
cin>>z4;

if(z4=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"5. What is the basic unit of life?"<<endl;
cout<<"a. blood"<<endl;
cout<<"b. heart"<<endl;
cout<<"c. brain"<<endl;
cout<<"d. cell"<<endl;
cin>>z5;

if(z5=='d')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: D \a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"6. Who is the father of biology?"<<endl;
cout<<"a. Socrates"<<endl;
cout<<"b. Aristotle"<<endl;
cout<<"c. Plato"<<endl;
cout<<"d. none of the above"<<endl;
cin>>z6;

if(z6=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"7. What is the smallest planet in the solar system?"<<endl;
cout<<"a. Pluto"<<endl;
cout<<"b. Mercury"<<endl;
cout<<"c. Mars"<<endl;
cout<<"d. Ceres"<<endl;
cin>>z7;

if(z7=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"8. Astronomy is under what field of science?"<<endl;
cout<<"a. physics"<<endl;
cout<<"b. chemistry"<<endl;
cout<<"c. biology"<<endl;
cout<<"d. none of the above"<<endl;
cin>>z8;

if(z8=='d')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: D\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"9. Who is the cartoon character also known as BOY - GENIUS?"<<endl;
cout<<"a. Ash Ketchum"<<endl;
cout<<"b. Spongebob Squarepants"<<endl;
cout<<"c. Jimmy Neutron"<<endl;
cout<<"d. Astroboy"<<endl;
cin>>z9;
if(z9=='c')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"10. What is the highest level of mankind here in earth?"<<endl;
cout<<"a. humans"<<endl;
cout<<"b. animals"<<endl;
cout<<"c. microbes"<<endl;
cout<<"d. none of the above"<<endl;
cin>>z10;
if(z10=='a')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}




cout<<"^_^"<<endl;
cout<<"You have "<<easyx<<" correct answers."<<endl;
cout<<"You have "<<easyy<<" wrong answers."<<endl;
cout<<"Print your score. "<<endl;
cout<<"Input name of output text file: "<<endl;
cin>>aaa;
group7a=fopen(aaa,"w");
fprintf(group7a,"EASY ROUND %d\n",file1);
fprintf(group7a,"Correct answers = %d\n",easyx);
fprintf(group7a,"Wrong answers = %d\n",easyy);
fclose(group7a);


cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAMER AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";



break;

}
case 4:
{
cout<<"Average Round"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
cout<<"\n\n\n\nAVERAGE ROUND IS ALL ABOUT PHYSICAL SCIENCE.\n\n\n\n";
cout<<"1.What is the first man-made satelite?"<<endl;
cout<<"a. sputnik1"<<endl;
cout<<"b. sputnik3"<<endl;
cout<<"c. apollo1"<<endl;
cout<<"d. apollo11"<<endl;
cin>>y1;
if(y1=='a')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"2.What makes Uranus blue?"<<endl;
cout<<"a. carbon dioxide"<<endl;
cout<<"b. helium"<<endl;
cout<<"c. methane"<<endl;
cout<<"d. hydrogen"<<endl;
cin>>y2;
if(y2=='c')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"3.What is the largest asteroid?"<<endl;
cout<<"a. eris"<<endl;
cout<<"b. ceres"<<endl;
cout<<"c. pluto"<<endl;
cout<<"d. comets"<<endl;
cin>>y3;
if(y3=='b')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"4.What is the largest mountain in the solar system?"<<endl;
cout<<"a. mt.apo"<<endl;
cout<<"b. mt.everest"<<endl;
cout<<"c. olympus wind"<<endl;
cout<<"d. olympus mons"<<endl;
cin>>y4;
if(y4=='d')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: D\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"5.What makes mars red?"<<endl;
cout<<"a. helium"<<endl;
cout<<"b. iron oxide"<<endl;
cout<<"c. hydrogen"<<endl;
cout<<"d. methane"<<endl;
cin>>y5;
if(y5=='b')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"6.What is the hottest planet in the solar system?"<<endl;
cout<<"a. mercury"<<endl;
cout<<"b. jupiter"<<endl;
cout<<"c. venus"<<endl;
cout<<"d. earth"<<endl;
cin>>y6;
if(y6=='c')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"7.What is the nearest point of a planet to the sun?"<<endl;
cout<<"a. perihelion"<<endl;
cout<<"b. aphelion"<<endl;
cout<<"c. perigee"<<endl;
cout<<"d. apogee"<<endl;
cin>>y7;
if(y7=='a')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"8. When did the first manned moon landing happen?"<<endl;
cout<<"a. May 6, 1969"<<endl;
cout<<"b. July 16, 1908"<<endl;
cout<<"c. July 21, 1969"<<endl;
cout<<"d. none of the above"<<endl;
cin>>y8;
if(y8=='c')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"9. What is the biggest moon of Jupiter?"<<endl;
cout<<"a. Ganymede"<<endl;
cout<<"b. Callisto"<<endl;
cout<<"c. Io"<<endl;
cout<<"d. Europa"<<endl;
cin>>y9;
if(y9=='a')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"10. What were the first creatures in this world to fly?"<<endl;
cout<<"a. birds"<<endl;
cout<<"b. insects"<<endl;
cout<<"c. butterflies"<<endl;
cout<<"d. none of the above"<<endl;
cin>>y10;
if(y10=='b')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}

cout<<"^_^"<<endl;
cout<<"You have "<<avex<<" correct answers."<<endl;
cout<<"You have "<<avey<<" wrong answers."<<endl;
cout<<"Print your score. "<<endl;
cout<<"Input name of output text file: "<<endl;
cin>>bbb;
group7b=fopen(bbb,"w");
fprintf(group7b,"AVERAGE ROUND %d\n",file2);
fprintf(group7b,"Correct answers = %d\n",avex);
fprintf(group7b,"Wrong answers = %d\n",avey);
fclose(group7b);

cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";


break;

}
case 5:
{
cout<<"DIFFICULT ROUND"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
cout<<"\n\n\n\nDIFFICULT ROUND IS ALL ABOUT SCIENTIFIC NAMES\n\n\n\n";
cout<<"1. What is the scientific name of bat?"<<endl;
cout<<"a. Order Chiroptera"<<endl;
cout<<"b. Order Cetacea"<<endl;
cout<<"c. Order Carnivora"<<endl;
cout<<"d. Order Casanova"<<endl;
cin>>x1;
if(x1=='a')
{
hardx=hardx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
hardy=hardy+1;
cout<<"IT'S WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"2. What is the scientific name of blue whale?"<<endl;
cout<<"a. Balaeniceps rex"<<endl;
cout<<"b. Balaenoptera musculus"<<endl;
cout<<"c. Branta canadensis"<<endl;
cout<<"d. Bufo bufo"<<endl;
cin>>x2;
if(x2=='b')
{
hardx=hardx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
hardy=hardy+1;
cout<<"IT'S WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
 
Was This Post Helpful? 0
  • +
  • -

#5 cziel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 22-August 09

Re: Classes for a Quiz Program

Posted 22 August 2009 - 09:39 PM

no, you don't need to apologize...

uhmm can you help me make it? because i really have troubles converting it to class form...i just started learning c++ so i am not a professional...
Was This Post Helpful? 0
  • +
  • -

#6 Elcric  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 101
  • View blog
  • Posts: 453
  • Joined: 02-May 09

Re: Classes for a Quiz Program

Posted 22 August 2009 - 10:10 PM

Hello, :D

I am thinking. Other people will jump in with ideas as we talk and they will also help you. But let me share my thought process with you as I go along.

To get more than one class we have to agree on your base class. A class is an abstract intangible type.

It looks like we can use question as your base class and then have the different types of questions as your derived classes. How does that sound to you?
Was This Post Helpful? 0
  • +
  • -

#7 cziel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 22-August 09

Re: Classes for a Quiz Program

Posted 22 August 2009 - 10:19 PM

..uhmmm ill try it


thank you very much for your help i really appreciate it

:D

..uhmmm another thing is i really dont know how to make or use classes...can you teach me how?/
Was This Post Helpful? 0
  • +
  • -

#8 Elcric  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 101
  • View blog
  • Posts: 453
  • Joined: 02-May 09

Re: Classes for a Quiz Program

Posted 22 August 2009 - 10:56 PM

Hello,

This is a very rough start.

[code]
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;

class Easy
{

private:

char user[10];
char pass[10];


public:

void password();

};

class Average
{

private:

char user[10];
char pass[10];


public:

void password();

};

class Difficult
{

private:

char user[10];
char pass[10];


public:

void password();

};

//************************************
// MAIN() FUNCTION.
//************************************
int main(int argc, char* argv[])
{
FILE *group7a;
FILE *group7b;
FILE *group7c;
char aaa[40];
char bbb[40];
char ccc[40];
char user[10];
char pass[10];
int file1=1;
int file2=2;
int file3=3;
int easyx=0;
int easyy=0;
int avex=0;
int avey=0;
int hardx=0;
int hardy=0;
int hamp;
char hatch;
char z1=0;
char z2=0;
char z3=0;
char z4=0;
char z5=0;
char z6=0;
char z7=0;
char z8=0;
char z9=0;
char z10=0;
char y1=0;
char y2=0;
char y3=0;
char y4=0;
char y5=0;
char y6=0;
char y7=0;
char y8=0;
char y9=0;
char y10=0;
char x1=0;
char x2=0;
char x3=0;
char x4=0;
char x5=0;
char x6=0;
char x7=0;
char x8=0;
char x9=0;
char x10=0;
hatch='n';
while(hatch!='y')
{
cout<<"Input username to continue:"<<endl;
cin>>user;
cout<<"Input password:"<<endl;

cin>>pass;
if((strcmp(user,"lasalle")==0)&&(strcmp(pass,"group7")==0))
{
cout<<"\nCORRECT USERNAME AND PASSWORD!\n"<<endl;
void password();
}else{
cout<<"\nWRONG USERNAME AND PASSWORD. ACCESS IS DENIED\n"<<endl;
exit(0);
}

void password();

cout<<"SCIENCE IS FUN GAME"<<endl;
cout<<"Main Menu"<<endl;
cout<<"1 - Game Description"<<endl;
cout<<"2 - Game Programmers"<<endl;
cout<<"3 - EASY ROUND"<<endl;
cout<<"4 - AVERAGE ROUND"<<endl;
cout<<"5 - DIFFICULT ROUND"<<endl;
cout<<"6 - Exit"<<endl;
cout<<"Choose "<<endl;
cin>>hamp;

switch(hamp)
{
case 1:
{
cout<<"PROGRAM DESCRIPTION: "<<endl;
cout<<"\n\n\n\n\n\n\n\n"<<endl;
cout<<"IT Project2"<<endl;
cout<<"Presented for "<<endl;
cout<<"The Partial Fullfillment"<<endl;
cout<<"In the course of"<<endl;
cout<<"Object Oriented Programming"<<endl;
cout<<"Presented to:"<<endl;
cout<<"Mr. Mark G. De Vera"<<endl;
cout<<"Presented by the:"<<endl;
cout<<"GROUP 7"<<endl;
cout<<"July 30, 2009"<<endl;

cout<<"^_^"<<endl;
cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";

break;
}
case 2:
{
cout<<"THE PROGRAMMERS:"<<endl;
cout<<"Gian Carlo P. Torres"<<endl;
cout<<"Wendel C. Balita"<<endl;
cout<<"Oscar Dimaculangan"<<endl;
cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";

break;
}
case 3:
{
cout<<"EASY ROUND:"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
cout<<"\n\n\n\nEasy round is all about GENERAL SCIENCE.\n\n\n\n";
cout<<"1.What is the first element in the periodic table of element?"<<endl;
cout<<"a. helium"<<endl;
cout<<"b. mercury"<<endl;
cout<<"c. hydrogen"<<endl;
cout<<"d. oxygen"<<endl;
cin>>z1;

if(z1=='c')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY! YOU ARE WRONG. THE CORRECT ANSWER IS: C\a "<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"2. What is the study of various species of life?"<<endl;
cout<<"a. chemistry"<<endl;
cout<<"b. biology"<<endl;
cout<<"c. physics"<<endl;
cout<<"d. physical science"<<endl;
cin>>z2;
if(z2=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY! YOU ARE WRONG. THE CORRECT ANSWER IS: B\a "<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"3. Who discovered the telephone?"<<endl;
cout<<"a. Thomas Edison"<<endl;
cout<<"b. Albert Einstein"<<endl;
cout<<"c. Galileo Galilei"<<endl;
cout<<"d. Jimmy Neutron"<<endl;
cin>>z3;

if(z3=='a')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"4. What is the biggest planet in the solar system?"<<endl;
cout<<"a. Mars"<<endl;
cout<<"b. Jupiter"<<endl;
cout<<"c. Saturn"<<endl;
cout<<"d. Vesta"<<endl;
cin>>z4;

if(z4=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"5. What is the basic unit of life?"<<endl;
cout<<"a. blood"<<endl;
cout<<"b. heart"<<endl;
cout<<"c. brain"<<endl;
cout<<"d. cell"<<endl;
cin>>z5;

if(z5=='d')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: D \a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"6. Who is the father of biology?"<<endl;
cout<<"a. Socrates"<<endl;
cout<<"b. Aristotle"<<endl;
cout<<"c. Plato"<<endl;
cout<<"d. none of the above"<<endl;
cin>>z6;

if(z6=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"7. What is the smallest planet in the solar system?"<<endl;
cout<<"a. Pluto"<<endl;
cout<<"b. Mercury"<<endl;
cout<<"c. Mars"<<endl;
cout<<"d. Ceres"<<endl;
cin>>z7;

if(z7=='b')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"8. Astronomy is under what field of science?"<<endl;
cout<<"a. physics"<<endl;
cout<<"b. chemistry"<<endl;
cout<<"c. biology"<<endl;
cout<<"d. none of the above"<<endl;
cin>>z8;

if(z8=='d')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: D\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"9. Who is the cartoon character also known as BOY - GENIUS?"<<endl;
cout<<"a. Ash Ketchum"<<endl;
cout<<"b. Spongebob Squarepants"<<endl;
cout<<"c. Jimmy Neutron"<<endl;
cout<<"d. Astroboy"<<endl;
cin>>z9;
if(z9=='c')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"10. What is the highest level of mankind here in earth?"<<endl;
cout<<"a. humans"<<endl;
cout<<"b. animals"<<endl;
cout<<"c. microbes"<<endl;
cout<<"d. none of the above"<<endl;
cin>>z10;
if(z10=='a')
{
easyx=easyx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
easyy=easyy+1;
cout<<"YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}

cout<<"^_^"<<endl;
cout<<"You have "<<easyx<<" correct answers."<<endl;
cout<<"You have "<<easyy<<" wrong answers."<<endl;
cout<<"Print your score. "<<endl;
cout<<"Input name of output text file: "<<endl;
cin>>aaa;
group7a=fopen(aaa,"w");
fprintf(group7a,"EASY ROUND %d\n",file1);
fprintf(group7a,"Correct answers = %d\n",easyx);
fprintf(group7a,"Wrong answers = %d\n",easyy);
fclose(group7a);

cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAMER AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";

break;

}
case 4:
{
cout<<"Average Round"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
cout<<"\n\n\n\nAVERAGE ROUND IS ALL ABOUT PHYSICAL SCIENCE.\n\n\n\n";
cout<<"1.What is the first man-made satelite?"<<endl;
cout<<"a. sputnik1"<<endl;
cout<<"b. sputnik3"<<endl;
cout<<"c. apollo1"<<endl;
cout<<"d. apollo11"<<endl;
cin>>y1;
if(y1=='a')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"2.What makes Uranus blue?"<<endl;
cout<<"a. carbon dioxide"<<endl;
cout<<"b. helium"<<endl;
cout<<"c. methane"<<endl;
cout<<"d. hydrogen"<<endl;
cin>>y2;
if(y2=='c')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"3.What is the largest asteroid?"<<endl;
cout<<"a. eris"<<endl;
cout<<"b. ceres"<<endl;
cout<<"c. pluto"<<endl;
cout<<"d. comets"<<endl;
cin>>y3;
if(y3=='b')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"4.What is the largest mountain in the solar system?"<<endl;
cout<<"a. mt.apo"<<endl;
cout<<"b. mt.everest"<<endl;
cout<<"c. olympus wind"<<endl;
cout<<"d. olympus mons"<<endl;
cin>>y4;
if(y4=='d')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: D\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"5.What makes mars red?"<<endl;
cout<<"a. helium"<<endl;
cout<<"b. iron oxide"<<endl;
cout<<"c. hydrogen"<<endl;
cout<<"d. methane"<<endl;
cin>>y5;
if(y5=='b')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"6.What is the hottest planet in the solar system?"<<endl;
cout<<"a. mercury"<<endl;
cout<<"b. jupiter"<<endl;
cout<<"c. venus"<<endl;
cout<<"d. earth"<<endl;
cin>>y6;
if(y6=='c')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"7.What is the nearest point of a planet to the sun?"<<endl;
cout<<"a. perihelion"<<endl;
cout<<"b. aphelion"<<endl;
cout<<"c. perigee"<<endl;
cout<<"d. apogee"<<endl;
cin>>y7;
if(y7=='a')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"8. When did the first manned moon landing happen?"<<endl;
cout<<"a. May 6, 1969"<<endl;
cout<<"b. July 16, 1908"<<endl;
cout<<"c. July 21, 1969"<<endl;
cout<<"d. none of the above"<<endl;
cin>>y8;
if(y8=='c')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"9. What is the biggest moon of Jupiter?"<<endl;
cout<<"a. Ganymede"<<endl;
cout<<"b. Callisto"<<endl;
cout<<"c. Io"<<endl;
cout<<"d. Europa"<<endl;
cin>>y9;
if(y9=='a')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"10. What were the first creatures in this world to fly?"<<endl;
cout<<"a. birds"<<endl;
cout<<"b. insects"<<endl;
cout<<"c. butterflies"<<endl;
cout<<"d. none of the above"<<endl;
cin>>y10;
if(y10=='b')
{
avex=avex+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
avey=avey+1;
cout<<"SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a"<<endl;
}

cout<<"^_^"<<endl;
cout<<"You have "<<avex<<" correct answers."<<endl;
cout<<"You have "<<avey<<" wrong answers."<<endl;
cout<<"Print your score. "<<endl;
cout<<"Input name of output text file: "<<endl;
cin>>bbb;
group7b=fopen(bbb,"w");
fprintf(group7b,"AVERAGE ROUND %d\n",file2);
fprintf(group7b,"Correct answers = %d\n",avex);
fprintf(group7b,"Wrong answers = %d\n",avey);
fclose(group7b);

cout<<"\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout<<"THANK YOU!\n\n\n\n\n";

break;

}
case 5:
{
cout<<"DIFFICULT ROUND"<<endl;
cout<<"GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS"<<endl;
cout<<"\n\n\n\nDIFFICULT ROUND IS ALL ABOUT SCIENTIFIC NAMES\n\n\n\n";
cout<<"1. What is the scientific name of bat?"<<endl;
cout<<"a. Order Chiroptera"<<endl;
cout<<"b. Order Cetacea"<<endl;
cout<<"c. Order Carnivora"<<endl;
cout<<"d. Order Casanova"<<endl;
cin>>x1;
if(x1=='a')
{
hardx=hardx+1;
cout<<"YOUR ANSWER IS CORRECT!"<<endl;
}else{
hardy=hardy+1;
cout<<"IT'S WRONG. THE CORRECT ANSWER IS: A\a"<<endl;
}
cout<<"\n\n\n\n\n\n\n\n\n\n";
cout<<"2. What is the scientific name of blue whale?"<<endl;
cout<<"a. Balaeniceps rex"<<endl;
cout<<"b. Balaenoptera musculus"<<endl;
cout<<"c. Branta canadensis"<<endl;
cout<<"d. Bufo bufo"<<endl;
cin>>x2;
if(x2=='b')
Was This Post Helpful? 1
  • +
  • -

#9 cziel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 22-August 09

Re: Classes for a Quiz Program

Posted 22 August 2009 - 11:03 PM

:D :D :D :D :D :D


im really grateful to you ....
thank you very much ^^
sorry for the trouble....
thank you thank you THANK YOU!!!!
Was This Post Helpful? 0
  • +
  • -

#10 Elcric  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 101
  • View blog
  • Posts: 453
  • Joined: 02-May 09

Re: Classes for a Quiz Program

Posted 23 August 2009 - 01:25 AM

Hello, :D

You are welcome.

This is the next step. Identifying the data members of each class.

Then you have to add the get and set functions for each data member.

[code]
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;

class Easy
{

private:

char m_user[10];
char m_pass[10];

char m_z1;
char m_z2;
char m_z3;
char m_z4;
char m_z5;
char m_z6;
char m_z7;
char m_z8;
char m_z9;
char m_z10;

int m_easyx;
int m_easyy;

char m_aaa[40];


public:



void password();

};

class Average
{

private:

char m_user[10];
char m_pass[10];

char m_y1;
char m_y2;
char m_y3;
char m_y4;
char m_y5;
char m_y6;
char m_y7;
char m_y8;
char m_y9;
char m_y10;

int m_avex;
int m_avey;

char m_bbb[40];

public:

void password();

};

class Difficult
{

private:

char m_user[10];
char m_pass[10];

char m_x1;
char m_x2;
char m_x3;
char m_x4;
char m_x5;
char m_x6;
char m_x7;
char m_x8;
char m_x9;
char m_x10;

int m_hardx;
int m_hardy;

char m_ccc[40];


public:

void password();

};

//************************************
// MAIN() FUNCTION.
//************************************
int main(int argc, char* argv[])
{
FILE *group7a;
FILE *group7b;
FILE *group7c;

char aaa[40];
char bbb[40];
char ccc[40];

char user[10];
char pass[10];

int file1 = 1;
int file2 = 2;
int file3 = 3;

int hamp;
char hatch;

char x1 = 0;
char x2 = 0;
char x3 = 0;
char x4 = 0;
char x5 = 0;
char x6 = 0;
char x7 = 0;
char x8 = 0;
char x9 = 0;
char x10 = 0;

int hardx = 0;
int hardy = 0;

char y1 = 0;
char y2 = 0;
char y3 = 0;
char y4 = 0;
char y5 = 0;
char y6 = 0;
char y7 = 0;
char y8 = 0;
char y9 = 0;
char y10 = 0;

int avex = 0;
int avey = 0;

char z1 = 0;
char z2 = 0;
char z3 = 0;
char z4 = 0;
char z5 = 0;
char z6 = 0;
char z7 = 0;
char z8 = 0;
char z9 = 0;
char z10 = 0;

int easyx = 0;
int easyy = 0;

hatch = 'n';
while( hatch != 'y' )
{
cout << "Input username to continue:" << endl;
cin >> user;

cout << "Input password:" << endl;
cin >> pass;

if( ( strcmp ( user, "lasalle" ) == 0 ) && ( strcmp ( pass, "group7" ) == 0 ) )
{
cout << "\nCORRECT USERNAME AND PASSWORD!\n" << endl;
void password();
} else
{
cout << "\nWRONG USERNAME AND PASSWORD. ACCESS IS DENIED\n" << endl;
exit(0);
}

void password();

cout << "SCIENCE IS FUN GAME" << endl;
cout << "Main Menu" << endl;
cout << "1 - Game Description" << endl;
cout << "2 - Game Programmers" << endl;
cout << "3 - EASY ROUND" << endl;
cout << "4 - AVERAGE ROUND" << endl;
cout << "5 - DIFFICULT ROUND" << endl;
cout << "6 - Exit" << endl;
cout << "Choose " << endl;
cin >> hamp;

switch(hamp)
{
case 1:
{
cout << "PROGRAM DESCRIPTION: " << endl;
cout << "\n\n\n\n\n\n\n\n" << endl;
cout << "IT Project2" << endl;
cout << "Presented for " << endl;
cout << "The Partial Fullfillment" << endl;
cout << "In the course of" << endl;
cout << "Object Oriented Programming" << endl;
cout << "Presented to:" << endl;
cout << "Mr. Mark G. De Vera" << endl;
cout << "Presented by the:" << endl;
cout << "GROUP 7" << endl;
cout << "July 30, 2009" <<endl;
cout << "^_^" << endl;
cout << "\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout << "THANK YOU!\n\n\n\n\n";
break;
}
case 2:
{
cout << "THE PROGRAMMERS:" << endl;
cout << "Gian Carlo P. Torres" << endl;
cout << "Wendel C. Balita" << endl;
cout << "Oscar Dimaculangan" << endl;
cout << "\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAME AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout << "THANK YOU!\n\n\n\n\n";
break;
}
case 3:
{
cout << "EASY ROUND:" << endl;
cout << "GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS" << endl;
cout << "\n\n\n\nEasy round is all about GENERAL SCIENCE.\n\n\n\n";
cout << "1.What is the first element in the periodic table of element?" << endl;
cout << "a. helium" << endl;
cout << "b. mercury" << endl;
cout << "c. hydrogen" << endl;
cout << "d. oxygen" << endl;
cin >> z1;
if( z1 == 'c' )
{
easyx = easyx + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else{
easyy = easyy + 1;
cout << "SORRY! YOU ARE WRONG. THE CORRECT ANSWER IS: C\a " << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "2. What is the study of various species of life?" << endl;
cout << "a. chemistry" << endl;
cout << "b. biology" << endl;
cout << "c. physics" << endl;
cout << "d. physical science" << endl;
cin >> z2;
if( z2 == 'b' )
{
easyx = easyx + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
easyy = easyy + 1;
cout << "SORRY! YOU ARE WRONG. THE CORRECT ANSWER IS: B\a " << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "3. Who discovered the telephone?" << endl;
cout << "a. Thomas Edison" << endl;
cout << "b. Albert Einstein" << endl;
cout << "c. Galileo Galilei" << endl;
cout << "d. Jimmy Neutron" << endl;
cin >> z3;
if( z3 == 'a' )
{
easyx = easyx + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
easyy = easyy + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "4. What is the biggest planet in the solar system?" << endl;
cout << "a. Mars" << endl;
cout << "b. Jupiter" << endl;
cout << "c. Saturn" << endl;
cout << "d. Vesta" << endl;
cin >> z4;
if( z4 == 'b' )
{
easyx = easyx + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
easyy = easyy + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "5. What is the basic unit of life?" << endl;
cout << "a. blood" << endl;
cout << "b. heart" << endl;
cout << "c. brain" << endl;
cout << "d. cell" << endl;
cin >> z5;
if( z5 == 'd' )
{
easyx = easyx + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
easyy = easyy + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: D \a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "6. Who is the father of biology?" << endl;
cout << "a. Socrates" << endl;
cout << "b. Aristotle" << endl;
cout << "c. Plato" << endl;
cout << "d. none of the above" << endl;
cin >> z6;
if( z6 == 'b' )
{
easyx = easyx + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
easyy = easyy + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "7. What is the smallest planet in the solar system?" << endl;
cout << "a. Pluto" << endl;
cout << "b. Mercury" << endl;
cout << "c. Mars" << endl;
cout << "d. Ceres" << endl;
cin >> z7;
if( z7 == 'b' )
{
easyx = easyx + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
easyy = easyy + 1;
cout << "YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: B\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "8. Astronomy is under what field of science?" << endl;
cout << "a. physics" << endl;
cout << "b. chemistry" << endl;
cout << "c. biology" << endl;
cout << "d. none of the above" <<endl;
cin >> z8;
if( z8 == 'd' )
{
easyx = easyx + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
easyy = easyy + 1;
cout << "YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: D\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "9. Who is the cartoon character also known as BOY - GENIUS?" << endl;
cout << "a. Ash Ketchum" << endl;
cout << "b. Spongebob Squarepants" << endl;
cout << "c. Jimmy Neutron" << endl;
cout << "d. Astroboy" << endl;
cin >> z9;
if( z9 == 'c' )
{
easyx = easyx + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
easyy = easyy + 1;
cout << "YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: C\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "10. What is the highest level of mankind here in earth?" << endl;
cout << "a. humans" << endl;
cout << "b. animals" << endl;
cout << "c. microbes" << endl;
cout << "d. none of the above" << endl;
cin >> z10;
if( z10 == 'a' )
{
easyx = easyx + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
easyy = easyy + 1;
cout << "YOUR ANSWER IS WRONG. THE CORRECT ANSWER IS: A\a" << endl;
}
cout << "^_^" << endl;
cout << "You have " << easyx << " correct answers." << endl;
cout << "You have " << easyy << " wrong answers." << endl;
cout << "Print your score. " << endl;
cout << "Input name of output text file: " << endl;
cin >> aaa;
group7a = fopen( aaa, "w" );
fprintf( group7a, "EASY ROUND %d\n", file1 );
fprintf( group7a, "Correct answers = %d\n", easyx );
fprintf( group7a, "Wrong answers = %d\n", easyy );
fclose( group7a );
cout << "\n\n\n\n\nYOU WILL BE ASKED TO INPUT YOUR USERNAMER AND PASSWORD AGAIN FOR THE SECURITY OF THE PROGRAM\n";
cout << "THANK YOU!\n\n\n\n\n";
break;
}
case 4:
{
cout << "Average Round" << endl;
cout << "GENERAL RULE: ALL ANSWERS SHOULD BE IN SMALL LETTERS" << endl;
cout << "\n\n\n\nAVERAGE ROUND IS ALL ABOUT PHYSICAL SCIENCE.\n\n\n\n";
cout << "1.What is the first man-made satelite?" << endl;
cout << "a. sputnik1" << endl;
cout << "b. sputnik3" << endl;
cout << "c. apollo1" << endl;
cout << "d. apollo11" << endl;
cin >> y1;
if( y1 == 'a' )
{
avex = avex + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
avey = avey + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "2.What makes Uranus blue?" << endl;
cout << "a. carbon dioxide" << endl;
cout << "b. helium" << endl;
cout << "c. methane" << endl;
cout << "d. hydrogen" << endl;
cin >> y2;
if( y2 == 'c' )
{
avex = avex + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
} else
{
avey = avey + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "3.What is the largest asteroid?" << endl;
cout << "a. eris" << endl;
cout << "b. ceres" << endl;
cout << "c. pluto" << endl;
cout << "d. comets" << endl;
cin >> y3;
if( y3 == 'b' )
{
avex = avex + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
avey = avey + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "4.What is the largest mountain in the solar system?" << endl;
cout << "a. mt.apo" << endl;
cout << "b. mt.everest" << endl;
cout << "c. olympus wind" << endl;
cout << "d. olympus mons" << endl;
cin >> y4;
if( y4 == 'd' )
{
avex = avex + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
avey = avey + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: D\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "5.What makes mars red?" << endl;
cout << "a. helium" << endl;
cout << "b. iron oxide" << endl;
cout << "c. hydrogen" << endl;
cout << "d. methane" << endl;
cin >> y5;
if( y5 == 'b' )
{
avex = avex + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
avey = avey + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "6.What is the hottest planet in the solar system?" << endl;
cout << "a. mercury" << endl;
cout << "b. jupiter" << endl;
cout << "c. venus" << endl;
cout << "d. earth" << endl;
cin >> y6;
if( y6 == 'c' )
{
avex = avex + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
avey = avey + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "7.What is the nearest point of a planet to the sun?" << endl;
cout << "a. perihelion" << endl;
cout << "b. aphelion" << endl;
cout << "c. perigee" << endl;
cout << "d. apogee" << endl;
cin >> y7;
if( y7 == 'a' )
{
avex = avex + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
avey = avey + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "8. When did the first manned moon landing happen?" << endl;
cout << "a. May 6, 1969" << endl;
cout << "b. July 16, 1908" << endl;
cout << "c. July 21, 1969" << endl;
cout << "d. none of the above" << endl;
cin >> y8;
if( y8 == 'c' )
{
avex = avex + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
avey = avey + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: C\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "9. What is the biggest moon of Jupiter?" << endl;
cout << "a. Ganymede" << endl;
cout << "b. Callisto" << endl;
cout << "c. Io" << endl;
cout << "d. Europa" << endl;
cin >> y9;
if( y9 == 'a' )
{
avex = avex + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
avey = avey + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: A\a" << endl;
}
cout << "\n\n\n\n\n\n\n\n\n\n";
cout << "10. What were the first creatures in this world to fly?" << endl;
cout << "a. birds" << endl;
cout << "b. insects" << endl;
cout << "c. butterflies" << endl;
cout << "d. none of the above" << endl;
cin >> y10;
if( y10 == 'b' )
{
avex = avex + 1;
cout << "YOUR ANSWER IS CORRECT!" << endl;
}else
{
avey = avey + 1;
cout << "SORRY YOU ARE WRONG. THE CORRECT ANSWER IS: B\a" << endl;
}
cout << "^_^" << endl;
cout << "You have " << avex << " correct answers." << endl;
Was This Post Helpful? 1
  • +
  • -

#11 cziel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 22-August 09

Re: Classes for a Quiz Program

Posted 23 August 2009 - 01:52 AM

thank you very much for your help...i mean it is really a BIG help....

ThANKS!!!! i really appreciate it..and at the same time i am also learning various infos in c++ thank you very much

is there a next step after that???
or is it finish???
im really sorry for giving you so much trouble...
and i am not giving so much help..
im really sorry but thanks again for the help
Was This Post Helpful? 0
  • +
  • -

#12 cziel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 22-August 09

Re: Classes for a Quiz Program

Posted 23 August 2009 - 03:04 AM

Quote

Then you have to add the get and set functions for each data member.



what is a get and set function?? i never heard of it though...sorry
Was This Post Helpful? 0
  • +
  • -

#13 Lillefix  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 37
  • View blog
  • Posts: 204
  • Joined: 19-September 08

Re: Classes for a Quiz Program

Posted 23 August 2009 - 03:42 AM

I believe I would have done something like this:
class Question
{
	private:
		string problem;			//The question
		string options[4];		//The possibilities
		char answer;			//The correct answer, e.q (a, b, c or d)
		
	public:
		Question();												//Empty constructor
		Question(string, string, string, string, string, char);	//Set the variables
		int askQuestion();										//Print the question, ask for input, return 1 upon correct answer, else return 0
};
class Quiz
{
	private:
		int numQuestions;
		Question questions[10];
		
	public:
		Quiz();
		bool addQuestion(Question);		//Returns true if the question was added, false if there is no more room
		int startQuiz();				//Returns the number of correct answers
		int getNumQuestions();			//Returns numQuestions
};

Was This Post Helpful? 0
  • +
  • -

#14 cziel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 22-August 09

Re: Classes for a Quiz Program

Posted 23 August 2009 - 03:49 AM

thank you for the reply

but i dont quite understand this code
class Question
{
	private:
		string problem;			//The question
		string options[4];		//The possibilities
		char answer;			//The correct answer, e.q (a, b, c or d)
	   
	public:
		Question();												//Empty constructor
		Question(string, string, string, string, string, char);	//Set the variables
		int askQuestion();										//Print the question, ask for input, return 1 upon correct answer, else return 0
};
class Quiz
{
	private:
		int numQuestions;
		Question questions[10];
	   
	public:
		Quiz();
		bool addQuestion(Question);		//Returns true if the question was added, false if there is no more room
		int startQuiz();				//Returns the number of correct answers
		int getNumQuestions();			//Returns numQuestions
};


Was This Post Helpful? 0
  • +
  • -

#15 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1000
  • View blog
  • Posts: 4,181
  • Joined: 14-February 08

Re: Classes for a Quiz Program

Posted 23 August 2009 - 03:50 AM

Hi

Because you are using private variables you will not be able to access them outside of the class, the way to do this is to create a public function with access to the private variable. So a function within the class.

an example
int getEasyX() { return m_easyx; }

void setEasyX(int m_x)
{
   m_easyx = m_x;
}



So if you want to use m_easyx you can call it using the get function
if(getEasyX() < 10)
{
	// do stuff
	setEasyX(2);
}



These are just examples of course but I hope you get the idea :)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2