473,770 Members | 4,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help in designing a quiz

Hey everyone just designing a quiz for school and managed to write the
code for the questions and answers thou i have to add scores and at the
end an overall score does anyone have any idea what to do or what i am
talkin about

Apr 19 '06 #1
16 4197
C++ Hell wrote:
Hey everyone just designing a quiz for school and managed to write the
code for the questions and answers thou i have to add scores and at the
end an overall score does anyone have any idea what to do or what i am
talkin about


What does that have to do with the C++ programming language?

Regards,
Ben
Apr 19 '06 #2

"C++ Hell" <jc*********@ho tmail.com> wrote in message
news:11******** **************@ t31g2000cwb.goo glegroups.com.. .
Hey everyone just designing a quiz for school and managed to write the
code for the questions and answers thou i have to add scores and at the
end an overall score does anyone have any idea what to do or what i am
talkin about


I'm going to go out on a limb and assme that you're talking about a program
you're writing (in C++) that does what you're describing? If so, then
what's the problem you're having, exactly? What have you got written so
far, and what's it doing (or not doing) that's giving you problems? We're
not going to just write your code for you, you know. :-)

-Howard


Apr 19 '06 #3
Sorry guys yea its in C++ programmin in visual basic, dont expect you
to write it for me just wonderin in which direction i can go, #include
<iostream>
using namespace std;
void main () {
cout << "FUN RUN QUIZ \n";
cout << " \n";
cout << "Instructio ns \n";
cout << "1)This game consists of 6 questions with three possible
answers to each question \n";
cout << "2)In each question you must only choose one answer out of the
possibley three by enterin the number of the answer and pressing
enter\n";
cout << "3)After each question you will be given the correct answer,
weather you were right or wrong and your score once you are happy
with this press enter \n";
cout << "4)Repeat instrustions 1-3 till you finish all questions \n";
cout << "5)Your overall score will be displayed at the end of the quiz
\n";
int result;
cout << "\n";
cout << "Question 1 \n";
cout << "What is the captial of england? \n";
cout << "1)Birminha m 2)London 3)Manchester \n";
cout << "\n";
cout << "Enter your answer \n";
cin >> result;
if (result == 1) {
cout<< "Wrong Answer (The correct answer was London)" << endl;
}
else if (result == 2) {
cout << "Correct Answer" << endl;
}
else if (result == 3) {
cout << "Wrong Answer (The correct answer was London)" << endl;
}
cout << "\n";
cout << "Question 2 \n";
cout << "Who wrote the Harry Potter books? \n";
cout << "1)J K Rowling 2)T K Rowling 3)H K Rowling \n";
cout << "\n";
cout << "Enter your answer \n";
cin >> result;
if (result == 1) {
cout<< "Correct Answer" << endl;
}
else if (result == 2) {
cout << "Wrong Answer (The correct answer was J K Rowling)" << endl;
}
else if (result == 3) {
cout << "Wrong Answer (The correct answer was J K Rowling)" << endl;
}
cout << "\n";
cout << "Question 3 \n";
cout << "Which actor stars in the film Into the Blue? \n";
cout << "1)Paul Walker 2)Tome Cruise 3)Will Smith \n";
cout << "\n";
cout << "Enter your answer \n";
cin >> result;
if (result == 1) {
cout<< "Correct Answer" << endl;
}
else if (result == 2) {
cout << "Wrong Answer (The correct answer was Paul Walker)" << endl;
}
else if (result == 3) {
cout << "Wrong Answer (The correct answer was Paul Walker)" << endl;
}
cout << "\n";
cout << "Question 4 \n";
cout << "What does DvD stand for? \n";
cout << "1)Digital Virtual Drive 2)Drive Video Disk 3)Digital Video
Disk \n";
cout << "\n";
cout << "Enter your answer \n";
cin >> result;
if (result == 1) {
cout<< "Wrong Answer (The correct answer was Digital Video Disk)" <<
endl;
}
else if (result == 2) {
cout << "Wrong Answer (The correct answer was Digital Video Disk)" <<
endl;
}
else if (result == 3) {
cout << "Correct Answer" << endl;
}
cout << "\n";
cout << "Question 5 \n";
cout << "In what year did Cadbury's first start producing chocolate?
\n";
cout << "1)1824 2)1830 3)1832 \n";
cout << "\n";
cout << "Enter your answer \n";
cin >> result;
if (result == 1) {
cout<< "Correct Answer" << endl;
}
else if (result == 2) {
cout << "Wrong Answer (The correct answer was 1824)" << endl;
}
else if (result == 3) {
cout << "Wrong Answer (The correct answer was 1824)" << endl;
}
cout << "\n";
cout << "Question 6 \n";
cout << "In what year sis mozart write his first three Symphonies? \n";
cout << "1)1761 2)1764 3)1765 \n";
cout << "\n";
cout << "Enter your answer \n";
cin >> result;
if (result == 1) {
cout<< "Wrong Answer (The correct answer was 1764)" << endl;
}
else if (result == 2) {
cout << "Correct Answer" << endl;
}
else if (result == 3) {
cout << "Wrong Answer (The correct answer was 1764)" << endl;
}
}

This is what i got, thanks for takin a look

Apr 19 '06 #4
C++ Hell wrote:
Sorry guys yea its in C++ programmin in visual basic, dont expect you
to write it for me just wonderin in which direction i can go,
What tutorials have you read? Have you curled up (preferably under a
blanket, before the fireplace, reading in the cherry light reflected from a
shovel) and read the stinkin' thing from the cover to at least the second
third?

(I admit I simply can't bring myself to read more than a page of /Advanced
CORBA Programming with C++/, but that's what I did with my first C book.
Modulo the fireplace [which is an oblique reference to Abraham Lincoln].)
#include
<iostream>
using namespace std;
void main () {
'void main' will increase the odds you get disappeared to GITMO. Use 'int
main'.
cout << "Question 1 \n";
cout << "What is the captial of england? \n";
cout << "1)Birminha m 2)London 3)Manchester \n";


One important topic in programming is removing duplication. Your code is
essentially a list of questions. If so, make it a real list:

struct question {
string what_is;
string options[3];
} questions[] = { "what is the...", { "NY", "DC", "CD" }...

etc. Learn to put things into a little table like that, then write a loop
statement that indexes and uses each item in the table.

Further learner questions might get a better response at a newsgroup which I
suspect is called news:alt.comp.l ang.learn.c-c++ , or something like that.

Good luck!

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Apr 19 '06 #5

C++ Hell wrote:
Sorry guys yea its in C++ programmin in visual basic, dont expect you
to write it for me just wonderin in which direction i can go


[code]

First of all, why don't make this a more OO program. For example, you
can encapsulate the questions in a class with three fields: The
question text, an array of possible choices and a number representing
the correct answer index in the array... This way the program would be
much smaller, and adding a new question wouldn't that hard...

About the score, what are you having trouble with? If you followed what
I said above, the score would be as simple as one condition for the
correctness of the answer and increamenting the number of correct
answers, then finally multiplying the latter by the weight of a single
correct answer...

Abdo Haji-Ali
Programmer
In|Framez

Apr 19 '06 #6
C++ Hell wrote:
Sorry guys yea its in C++ programmin in visual basic, dont expect you
to write it for me just wonderin in which direction i can go
Well, first off, you could use some well placed white space to
make things a bit more readable. Also, proofread the text quite
carefully before letting students at it.
, #include
<iostream>
using namespace std;
I tend to resist this, choosing to include the std:: in the calls.
That may just be because I have been forced, in the past, to
use a buggy compiler that had whacky things going on in
it's implementation of std:: so that this line often revealed
problems that could be avoided (not solved) by avoiding
the line.
void main () {
main returns int.
cout << "FUN RUN QUIZ \n";
cout << " \n";
cout << "Instructio ns \n";
cout << "1)This game consists of 6 questions with three possible
answers to each question \n";
cout << "2)In each question you must only choose one answer out of the
possibley three by enterin the number of the answer and pressing
Possible.
enter\n";
You need to deal with the possibility the user types other than
the integer you want. For example, if you display choices like

1)Birminham 2)London 3)Manchester

you need to deal with the possibility the user types any of
the following and a bunch more.

1) Manchester
99
Hello
(*&^9d8*&
It's Birmingham

One way is to read a line rather than what you've done (which
is read an integer) and then do some parsing on the line.
You could, for example, tell the user that anything that is
not an integer means the line is invalid, and pester the user
to re-enter that value.
cout << "3)After each question you will be given the correct answer,
weather you were right or wrong and your score once you are happy
with this press enter \n";
cout << "4)Repeat instrustions 1-3 till you finish all questions \n";
cout << "5)Your overall score will be displayed at the end of the quiz
\n";
int result;
cout << "\n";
cout << "Question 1 \n";
cout << "What is the captial of england? \n";
Capital. England.
cout << "1)Birminha m 2)London 3)Manchester \n";
cout << "\n";
You might want to experiment with better formatting of this.
Such as putting the answers in a column rather than a row.

What is the captial of England?
1)Birminham
2)London
3)Manchester

cout << "Enter your answer \n";
cin >> result;
if (result == 1) {
cout<< "Wrong Answer (The correct answer was London)" << endl;
}
else if (result == 2) {
cout << "Correct Answer" << endl;
}
else if (result == 3) {
cout << "Wrong Answer (The correct answer was London)" << endl;
}

[rest snipped]

You would produce something much more readable if you were
to collect your questions into some kind of table. For example,
make a class with some entries for: the text of the question,
the text of each guess, and the number of the correct answer.
Here I go coding at the terminal, so there are probably lots of
typos and syntax errors here.

class Question
{
public:
Question();
std::string GetQuestion();
void SetQuestion(std ::string);
// other functions go here
private:
std::string question;
std::vector<std ::string> answers;
int rightAnswer;
int givenAnswer;
};

Then you make a list (or maybe a vector) of questions and
fill it in. Then you step through the list in a loop, ask each
question, and record the answer. Note that you will need
to learn about std things string, vector, and list, and you
will probably want to learn something about iterators on
the last two. If your text has not yet introduced these things,
read ahead to the parts where it does. Learn them early,
use them often.

Look up the "rule of three" in the FAQ, to see what the
first few items are that go in at // other functions go here

This makes things much more flexible because the parts of
the test where you actually interact with the student are
in a single loop. You don't have to repeat all that stuff for
each question, the loop and list do that for you. You could
quite easily change such things as:
- give the right answer right away or prompt on wrong answers
to guess again or give the right answers only at the end
- keep a running score or only total up the score at the end
- only report the final right/wrong, produce a percent right,
change to a letter grade, or produce a full printout of the
test with marked up right/wrong answers.
- The test could be stored in a file and your prog could read
it in. Then the same prog could do any test, with an arbitrary
number of questions, each with an arbitrary number of
choices, and each worth an arbitrary score possibly based
on difficulty.
Socks

Apr 19 '06 #7
"C++ Hell" writes:
Sorry guys yea its in C++ programmin in visual basic, dont expect you
to write it for me just wonderin in which direction i can go,
<iostream>
using namespace std;
void main () {
cout << "FUN RUN QUIZ \n";
cout << " \n";
cout << "Instructio ns \n";
cout << "1)This game consists of 6 questions with three possible
answers to each question \n";
cout << "2)In each question you must only choose one answer out of the
possibley three by enterin the number of the answer and pressing
enter\n";

<snip>

You're doing it backwards! Write the program in a shell or stub form and get
it into a form you can live with. You can remember what "q 1" and "a 1"
stands for for a few minutes. Type it in concisely and then, after it is
working, and only then, type in the actual data. You have done all this
typing, there is so much of it that you can't see the forest for the trees,
and now you are going to have to type it all in again. As the others have
pointed out, get a structure of some form, minimize the redundancy and
duplication. You have a long linear list, OK for a novel but this is a
computer program. Certainly arrays or vectors of some sort are going to be
involved somehow in the final solution.

Do you want it to be fancy to impress someone. like an instructor? If not I
would use a simple array of const char* to contain the questions and another
(parallel) array for the answers and another parallel const array of int
for the proper numeric answers - the answer code, I guess. Clearly that
stuff all *belongs* in a struct or a class, parallel arrays are kind of out
of style. If they ever *were* in style.
Apr 19 '06 #8
osmium wrote:
YouÂ*haveÂ*aÂ*l ongÂ*linearÂ*li st,Â*OKÂ*forÂ*a Â*novelÂ*butÂ*t hisÂ*isÂ*a
computer program.Â*Â*Cer tainlyÂ*arrays *orÂ*vectorsÂ*o fÂ*someÂ*sortÂ* areÂ*goingÂ*to
be involved somehow in the final solution.


Part of being an advanced programmer is learning to go for the simple, not
advanced solution.

For example, my array was over-engineered. I could have gone simpler.
We just need a list of function calls:

ask("Who is buried in grant's tomb",
"grant",
"and his horse",
"nobody's buried in it because it's a tomb, not a plot");

ask("What is the eternal Tao",
"the known Tao",
"and the unknown Tao",
"eternally compiling ACE+TAO");

Note that my hypothetical ask() function will take care of the "?", the "1)
" numbers on the questions, etc.

The original poster is advised to start the program again, with 1 of these
ask() functions, and get it working before adding more. Then copy all the
strings over.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Apr 19 '06 #9
Phlip wrote:
osmium wrote:
You have a long linear list, OK for a novel but this is a
computer program. Certainly arrays or vectors of some sort are going to
be involved somehow in the final solution.


Part of being an advanced programmer is learning to go for the simple, not
advanced solution.

For example, my array was over-engineered. I could have gone simpler.
We just need a list of function calls:

ask("Who is buried in grant's tomb",
"grant",
"and his horse",
"nobody's buried in it because it's a tomb, not a plot");

ask("What is the eternal Tao",
"the known Tao",
"and the unknown Tao",
"eternally compiling ACE+TAO");

Note that my hypothetical ask() function will take care of the "?", the "1)
" numbers on the questions, etc.

The original poster is advised to start the program again, with 1 of these
ask() functions, and get it working before adding more. Then copy all the
strings over.


The important feature you have retained here is that it is still
basically tabular. You've got a function with args that effectively
acts as the columns in a table. So it's quite easy to add
another question, and it divorces the creation of questions
from the machinery of asking the question. This is good.
It means that the problem is being solved in the space of
the problem, as opposed to the space of C++ syntax.

In some ways this approach is simpler. Now, suppose he wants
to maintain the answers and make a report of the entire test?
Maybe a collection holding instancs of a class is the way to go
after all.

The way to decide how fancy to get, the way to decide how
elaborate is too elaborate, is to consider the changes that
are likely to be requested over the life of the code. If the code
has a lifespan that consists of "long enough to learn how to
use feature x" then you don't want any elaboration at all.

If the code is likely to last long enough for some instructor
to moan about the answers not being printed out in a nice
format that can be put in a book of remembrance of students
she has flunked, then some elaboration is good.

If the code is likely to get included in a library, and have
change requests thrown like darts in a pub for years,
it is important to be fairly heavy on the design effort.
Socks

Apr 19 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1855
by: Carolyn Gill | last post by:
I have already created an asp login/database for a learning/quiz section on a small site. There will be multiple quizzes through the site and what I need now would be help: tutorials or advice that a complete novice can understand/follow to create the following: A small simple quiz--for now each has just one question with 5 multi-choice buttons. On submit should send the answer to A) a database (using access for now) to track scoring...
5
5758
by: Vandana Rola | last post by:
Hello Everyone, I am a beginner in Javascript.I want to create fun quiz tool using javascript (no database). The feature of that tool is every question has five choices. The user needs to select three best choices. If they do, a message window pops up which says good choices or something and take them to next question. If they don't choose all of the best choices they get another message like try again but these are not the best choices...
4
7468
by: DAL | last post by:
I want to build my kid a program that cycles through questions (using a label for the question), and lets him choose one of two radio buttons for the right answer. How do I get every set of questions and answers to cycle through until the last question? Also, how can I give him the score after the last question. Thank you in advance. DAL. P.S. As a beginner, I figured I couldn't pass up the chance to learn something new, and to practice...
0
1653
by: philip | last post by:
hello, i am now developing a quiz application for my school using ASP.NET and SQL SERVER 2005, here is a senario: It will have 20 students for taking a quiz in a classroom, they have to answer randomly generated 100 questions in 90 minutes from database, each of those questions may have a picture (approximately 200K), and the picture is stored in the database as image type. i have 2 methods for retrieving 100 questions for each student.
2
3429
by: kenny | last post by:
I'm making a quiz to be posted on the internet. but I'm facing difficulties in finding a simple timer for the quiz (unlimited timing) which will keep on running regardless to the change of the page throughout the quiz. And well how to display the result of the quiz and te grade of the person who has taken the quiz....
0
4578
NoPeasHear
by: NoPeasHear | last post by:
I don't know what I am doing wrong... I used this tutorial... http://www.permadi.com/tutorial/flashMXQuiz/index.html It works with their quiz.xml file, but when I add an option for multiple correct answers, the results page always gives me a response of 0. What would I change from the tutorial to have multiple correct responses reflect in the results? <?xml version="1.0"?>
1
3092
by: korr | last post by:
Hi there, i'm trying to develop a quiz in flash. Searching on the net, I found a quiz in flashkit from sephiroth.it by Alessandro Crugnola. His quiz has a script that puts the questions and the answers in random order. What i'm looking for is to not select the answers by clicking the mouse, but using the keyPress handler. Using the keyPress handler the script selects only the first answer I tried a lot but i didn't find any solution.. 2...
5
7214
by: pefok | last post by:
Hello everyone, One of my course works is to implement a java based quiz system. the program consists of two modules one for the teacher to create, set questions , answers and the number of questions to be published, and the other one is to allow the student to run the quiz. the data for the quiz is stored in text files and the correct answers are encrypted. everytime the students take a quiz the result has to be stored and a report...
3
2218
by: empiresolutions | last post by:
I am building a app that creates quizzes. This is how it goes - - Create Quiz - Provide up to 10 different types of Quiz Results - Give up to 50 Questions - Each Question has up to 10 possible Answers. - Each Answer is assigned a Weighted value.... for each type of Quiz Result. - Weighted values are in the range of -6, 0, +6. - Each Quiz will also apply the same Weight range for if a M/F is taking and what of 6 age groups the taker is...
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10001
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.