Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Random Code Playback / Revised Scoring System / Etc

$
0
0
Hey,

For my first C++ project, I've decided to make a multiple choice quiz for my girlfriend - she is studying for her state-regulated exam to become a licensed hair stylist.

Currently there are 25 questions that get asked (with multiple choice answers (a, b, c or d)).
If you get the answer right: you are told so, a point gets added to the score, and you move on to the next question.
If you get the answer wrong: you are told the correct answer, and you move on to the next question.
At the end, a final score is given to the user.
Pretty basic stuff..

I'd like to step this up a notch....

A)How could I set the program up to ask the questions in a random order?

B)Right now the scoring system simply tallies the total number of correct answers.
If I wanted to take that number and convert it to a percentage that is associated with a grade (a, b, c, d, f), how would I do that?

C)I asked this question in another post, and got some great answers, but I wasn't really following some of the more detailed responses - a bit over my head at this point, but I want to do it anyways.... How could I set up a "table of contents" at the beginning of the program - one that would allow the user to select a section of questions to jump to?
One of the responses mentioned using IF and ELSE IF statements, but how exactly would I implement them in this code?

Here is my code for the program so far.
Please note, I'm only showing 3 of the 25 questions here, as the code is pretty repetitive - you get the idea.

#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{

//#######################################################################################
// Introduction to the program - Instructions on how to take the quiz.	

	cout<<"This is a multiple choice quiz in Hair Cut Theory"<<endl<<endl<<endl;
	cout<<"INSTRUCTIONS:"<<endl<<endl;
	cout<<"I will ask you a series of questions, to which you may reply by"<<endl;
	cout<<"pressing 'a', 'b', 'c', or 'd' followed by the 'enter' key."<<endl<<endl<<endl;
	system("pause");
	system("cls");

//#######################################################################################
// Introduces the variable that keeps track of the score.

	int addscore = 0;

//#######################################################################################
// Question 1.

	char answer1 = 'b';
	char input1;
	cout<<"Question 1."<<endl<<endl;
	cout<<"Achieving balance within a design can be accomplished"<<endl;
	cout<<"by understanding the head shape and:"<<endl<<endl;
	cout<<"a. Head Points"<<endl;
	cout<<"b. Reference Points"<<endl;
	cout<<"c. Four Corners"<<endl;
	cout<<"d. Technique Points"<<endl<<endl;
	cin.get(input1);
	cout<<endl;
		if (input1 == answer1)
		{
			cout<<"You are correct!"<<endl<<endl;
			addscore++;
		}
		else {
			cout<<"I'm sorry, but the correct answer was "<<answer1<<"."<<endl<<endl;
		}
		cin.get();
		system("pause");
		system("cls");

//#######################################################################################
// Question 2.

	char answer2 = 'a';
	char input2;
	cout<<"Question 2."<<endl<<endl;
	cout<<"The location of the four corners signals a change in the:"<<endl<<endl;
	cout<<"a. Head Shape"<<endl;
	cout<<"b. Bone Shape"<<endl;
	cout<<"c. Hair Texture"<<endl;
	cout<<"d. Hair Growth"<<endl<<endl;
	cin.get(input2);
	cout<<endl;
		if (input2 == answer2)
		{
			cout<<"You are correct!"<<endl<<endl;
			addscore++;
		}
		else {
			cout<<"I'm sorry, but the correct answer was "<<answer2<<"."<<endl<<endl;
		}
		cin.get();
		system("pause");
		system("cls");

//#######################################################################################
// Question 3.

	char answer3 = 'c';
	char input3;
	cout<<"Question 3."<<endl<<endl;
	cout<<"The two front corners represent the widest part of the:"<<endl<<endl;
	cout<<"a. Apex Area"<<endl;
	cout<<"b. Parietal Area"<<endl;
	cout<<"c. Bang Area"<<endl;
	cout<<"d. Nape Area"<<endl<<endl;
	cin.get(input3);
	cout<<endl;
		if (input3 == answer3)
		{
			cout<<"You are correct!"<<endl<<endl;
			addscore++;
		}
		else {
			cout<<"I'm sorry, but the correct answer was "<<answer3<<"."<<endl<<endl;
		}
		cin.get();
		system("pause");
		system("cls");

//#######################################################################################

// This is where the other 22 questions go - removed from the code to save space - you get the idea...

//#######################################################################################
// Test Results - The score is added up and presented to the user.

		cout<<"TEST RESULTS"<<endl<<endl<<endl;
		cout<<"You answered "<<addscore<<" of 25 questions correctly!"<<endl<<endl;

		system("pause");
}





Thanks in advance for the help guys!!!!

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>