Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Uni exercise.its easy if you know.please help me
New Posts  All Forums:Forum Nav:

So they told us to make a program in C++ without teaching us C++ and we have to find everything by our selves. So they want us to create a program which ask 3 questions and the user must choose between 4 answers in each question. 5 marks for the correct answer,0 for the wrong, -3 for the completely wrong and 3 for half right question. After that we have to sum up the 3 answers give a grade out of 15 and then show the right answers(btw i thought all the number giving in right and wrong answers and the sum that will be 15)

my program until now is like that :

#include "StdAfx.h"
#include <iostream>
using namespace std;

char main()
{

char a,b,c;

cout <<"The questions are from the 102CDE subject!\
";
cout <<"\
";

cout <<"Solving superposition problems we first have to:\
";
cout <<"\
";

cout <<"a) Consider one source at a time and replace the current sources by open circuit and the voltage sources by short circuit\
";
cout <<"b) Replace both current and voltage sources by open and short circuit respectively\
";
cout <<"c) Know Mesh analysis becasue its the same procedure\
";
cout <<"d) Apply same rules of Mesh analysis to calcualte currents and voltages\
";

cin >> a;

if (a=a)
{
}
else if (a=b)
{
}
else if (a=c)
{
}
else if (a=d)
(
)

cout <<"\
";

cout <<"In mesh analysis the loops are defined by looking at:\
";
cout <<"\
";

cout <<"a) DC sources\
";
cout <<"b) Resistors\
";
cout <<"c) Wires\
";
cout <<"d) DC and AC sources together\
";

cin >> b;
cout <<"\
";

cout <<"When the current and voltage pass through their zero values and increase to their maximum values in the same direction at the same time the current is said to be:\
";
cout <<"\
";

cout <<"a) In phase with the voltage\
";
cout <<"b) In phase with the current\
";
cout <<"c) Out of phase with the voltage\
";
cout <<"d) Out of phase with the current\
";

cin >>c;

cout <<"\
";

return 0;

}

and i dont know how to make the program read the answer of the user in each question-am currently working on the first question with the if function.
i hope i explain it right and i will be very thankful if you can help me
 MSI GT-725 GAMING LAPTOP (13 items)
CPUMotherboardGraphicsRAM
Q9000 INTEL MP45 ATI 4850 4gb
Hard DriveOptical DriveOSMouse
320 BLU RAY WINDOWS 7 64BIT CYBORG
RAZER
 MSI GT-725 GAMING LAPTOP (13 items)
CPUMotherboardGraphicsRAM
Q9000 INTEL MP45 ATI 4850 4gb
Hard DriveOptical DriveOSMouse
320 BLU RAY WINDOWS 7 64BIT CYBORG
RAZER
Quote:
also you dont need to use a variable when you are reading in user data.
example you could do. Alsom always use descriptive and meaningful variable names, it will make your life so much easier.

char userInpt;

// check to see what grade you will give the person
// your if else works ok
if correct do
or
and so on depending on your criteria.

Here is a little free code..

Code:
``````include <iostream>; // All you need right now
using namespace std;
void main()
{
// Set up variables
char userInput;

// now check if it was correct
// Since you are working with a char variable you need to do it this way
if( userInput == 'a')
else if(userInput == 'b')
// scoring code

// do this for each question
// by the end you have ther person score and can display it like so
cout << "You scored " << userGrade << " out of 15.\
";

// then just cout all of the questions with the correct answers.
// Simple you are done

cin.get();// this pauses the console.
}// end main``````
Good luck.
Edited by donkru - 3/30/11 at 1:02am
 Valery (13 items)
CPUMotherboardGraphicsRAM
i5 2500k GA-P67A-UD4-B3 Radeon 7970 Reference G. Skill Sniper
Hard DriveOptical DriveOSMonitor
Corsair NOVA SSD 64gb + 500gb Storage + 1TB Storag HP DVD burner Windows 7 64bit 37" 1080p60hz
KeyboardPowerCaseMouse
Razer Blackwidow Ultimate Rosewill Lightning 1000W Single Rail LianLi PC-K58 Razer Spectre
Razer Goliathus Speed
 Valery (13 items)
CPUMotherboardGraphicsRAM
i5 2500k GA-P67A-UD4-B3 Radeon 7970 Reference G. Skill Sniper
Hard DriveOptical DriveOSMonitor
Corsair NOVA SSD 64gb + 500gb Storage + 1TB Storag HP DVD burner Windows 7 64bit 37" 1080p60hz
KeyboardPowerCaseMouse
Razer Blackwidow Ultimate Rosewill Lightning 1000W Single Rail LianLi PC-K58 Razer Spectre