C# quiz program [on hold]
up vote
-1
down vote
favorite
I'm making a quiz program, and have got it to a state (thanks to this forum) where it will run through the program and grade (somewhat) accurately. My loops are set up so that the user has infinite chances to answer each question. What I have been fighting with now is how to alter the program so 1 attempt is allowed, and the questions answered incorrectly will be asked again in a second round.
What I have been trying implement and failing at is to:
- have the second else condition of each of my if/else loops advance to the next question, mark the incorrect questions somehow so they will be repeated, and finally display the correct responses in the second iteration of questioning, and allow a second attempt for incorrect questions.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mark11QuizBasic
{
class Program
{
static void Main(string args)
{
int scoreA = 0;
int scoreB = 0;
int scoreC = scoreA + scoreB;
string answer1 = "d";
string answer2 = "a";
string answer3 = "c";
string answer4 = "d";
string answer5 = "b";
string answer6 = "a";
string answer7 = "b";
string answer8 = "d";
string answer9 = "b";
string answer10 = "b";
Program.ClassHeader();//Method1
//n1
Console.WriteLine("");
Console.WriteLine("Answers are case sensitive. Please enter answers in lower case. The best possible score is 10.");
Console.WriteLine("");
bool KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. Which math subject is critical in astral navigation? " +
"a. Probability and Statistics, b. Differential Calculus, c. Basic Algebra, d. Trigonometry.");
answer1 = Console.ReadLine();
Console.Clear();
if ((answer1 != "a") && (answer1 != "b") && (answer1 != "c") && (answer1 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer1 == "d")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n1
//N2
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. A sloop is a sailboat with one mast. a. True, b. False.");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer2 == "a")
{
scoreB = scoreB + scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n2
//N3
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. Port is which side of a ship? " +
"a. Right, b. Back, c. Left, d. Front.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer3 == "c")
{
scoreC = scoreB + 1;//score
Console.WriteLine("Correct! Score: " + scoreC);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N3
//N4
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("4. Starboard is which side of a ship? a. Front, b. Back, c. Left, d. Right.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer4 == "d")
{
scoreA = scoreC + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N4
//N5
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("5. Seawater is safe to drink without purification. a.True or b. False");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer5 == "b")
{
scoreB = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N5
//n6
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("6. On a sailboat a sheet is: a. Ropes that controls rigging, b. A sail, c. A piece of bedding, d. A piece of paper.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer6 == "a")
{
scoreA = scoreB + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n6
//n7
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("7. On a sailboat a line is: a. Ropes that controls rigging, b. Ropes or cables that supports the rigging, c. A loose piece of general purpose rope, d. A rope used as a clothes line.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer7 == "b")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n7
//n8
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("8. What is a galley? a. A type of ship, b. A corridor on a ship, c. A ship’s kitchen, d. Both a and c.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer8 == "d")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n8
//n9
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("9. Salinity differs by ocean and locations, but on average sea water is what percent dissolved salt? a. 1%, b. 3.5%, c. 5.5%, d. 10%.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer9 == "b")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n9
//n10
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("10. North is 45° on a compass. a. True or b. False?");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer10 == "b")
{
scoreB = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n10
Console.ReadKey();
Console.WriteLine("Thanks for taking my quiz. Your Score is : " + scoreB);
}
static void ClassHeader()//Method 1
{
Console.WriteLine("Quiz Program");
}
}
}
I'm still very new at this so I'm trying to keep it very simple even if it is bloated. I'm posting the whole thing so y'all can see where I am as far as skill goes.
c#
New contributor
put on hold as off-topic by πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, 200_success, Jamal♦ 2 days ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, 200_success, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-1
down vote
favorite
I'm making a quiz program, and have got it to a state (thanks to this forum) where it will run through the program and grade (somewhat) accurately. My loops are set up so that the user has infinite chances to answer each question. What I have been fighting with now is how to alter the program so 1 attempt is allowed, and the questions answered incorrectly will be asked again in a second round.
What I have been trying implement and failing at is to:
- have the second else condition of each of my if/else loops advance to the next question, mark the incorrect questions somehow so they will be repeated, and finally display the correct responses in the second iteration of questioning, and allow a second attempt for incorrect questions.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mark11QuizBasic
{
class Program
{
static void Main(string args)
{
int scoreA = 0;
int scoreB = 0;
int scoreC = scoreA + scoreB;
string answer1 = "d";
string answer2 = "a";
string answer3 = "c";
string answer4 = "d";
string answer5 = "b";
string answer6 = "a";
string answer7 = "b";
string answer8 = "d";
string answer9 = "b";
string answer10 = "b";
Program.ClassHeader();//Method1
//n1
Console.WriteLine("");
Console.WriteLine("Answers are case sensitive. Please enter answers in lower case. The best possible score is 10.");
Console.WriteLine("");
bool KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. Which math subject is critical in astral navigation? " +
"a. Probability and Statistics, b. Differential Calculus, c. Basic Algebra, d. Trigonometry.");
answer1 = Console.ReadLine();
Console.Clear();
if ((answer1 != "a") && (answer1 != "b") && (answer1 != "c") && (answer1 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer1 == "d")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n1
//N2
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. A sloop is a sailboat with one mast. a. True, b. False.");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer2 == "a")
{
scoreB = scoreB + scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n2
//N3
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. Port is which side of a ship? " +
"a. Right, b. Back, c. Left, d. Front.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer3 == "c")
{
scoreC = scoreB + 1;//score
Console.WriteLine("Correct! Score: " + scoreC);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N3
//N4
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("4. Starboard is which side of a ship? a. Front, b. Back, c. Left, d. Right.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer4 == "d")
{
scoreA = scoreC + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N4
//N5
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("5. Seawater is safe to drink without purification. a.True or b. False");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer5 == "b")
{
scoreB = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N5
//n6
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("6. On a sailboat a sheet is: a. Ropes that controls rigging, b. A sail, c. A piece of bedding, d. A piece of paper.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer6 == "a")
{
scoreA = scoreB + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n6
//n7
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("7. On a sailboat a line is: a. Ropes that controls rigging, b. Ropes or cables that supports the rigging, c. A loose piece of general purpose rope, d. A rope used as a clothes line.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer7 == "b")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n7
//n8
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("8. What is a galley? a. A type of ship, b. A corridor on a ship, c. A ship’s kitchen, d. Both a and c.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer8 == "d")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n8
//n9
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("9. Salinity differs by ocean and locations, but on average sea water is what percent dissolved salt? a. 1%, b. 3.5%, c. 5.5%, d. 10%.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer9 == "b")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n9
//n10
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("10. North is 45° on a compass. a. True or b. False?");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer10 == "b")
{
scoreB = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n10
Console.ReadKey();
Console.WriteLine("Thanks for taking my quiz. Your Score is : " + scoreB);
}
static void ClassHeader()//Method 1
{
Console.WriteLine("Quiz Program");
}
}
}
I'm still very new at this so I'm trying to keep it very simple even if it is bloated. I'm posting the whole thing so y'all can see where I am as far as skill goes.
c#
New contributor
put on hold as off-topic by πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, 200_success, Jamal♦ 2 days ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, 200_success, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm making a quiz program, and have got it to a state (thanks to this forum) where it will run through the program and grade (somewhat) accurately. My loops are set up so that the user has infinite chances to answer each question. What I have been fighting with now is how to alter the program so 1 attempt is allowed, and the questions answered incorrectly will be asked again in a second round.
What I have been trying implement and failing at is to:
- have the second else condition of each of my if/else loops advance to the next question, mark the incorrect questions somehow so they will be repeated, and finally display the correct responses in the second iteration of questioning, and allow a second attempt for incorrect questions.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mark11QuizBasic
{
class Program
{
static void Main(string args)
{
int scoreA = 0;
int scoreB = 0;
int scoreC = scoreA + scoreB;
string answer1 = "d";
string answer2 = "a";
string answer3 = "c";
string answer4 = "d";
string answer5 = "b";
string answer6 = "a";
string answer7 = "b";
string answer8 = "d";
string answer9 = "b";
string answer10 = "b";
Program.ClassHeader();//Method1
//n1
Console.WriteLine("");
Console.WriteLine("Answers are case sensitive. Please enter answers in lower case. The best possible score is 10.");
Console.WriteLine("");
bool KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. Which math subject is critical in astral navigation? " +
"a. Probability and Statistics, b. Differential Calculus, c. Basic Algebra, d. Trigonometry.");
answer1 = Console.ReadLine();
Console.Clear();
if ((answer1 != "a") && (answer1 != "b") && (answer1 != "c") && (answer1 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer1 == "d")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n1
//N2
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. A sloop is a sailboat with one mast. a. True, b. False.");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer2 == "a")
{
scoreB = scoreB + scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n2
//N3
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. Port is which side of a ship? " +
"a. Right, b. Back, c. Left, d. Front.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer3 == "c")
{
scoreC = scoreB + 1;//score
Console.WriteLine("Correct! Score: " + scoreC);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N3
//N4
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("4. Starboard is which side of a ship? a. Front, b. Back, c. Left, d. Right.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer4 == "d")
{
scoreA = scoreC + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N4
//N5
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("5. Seawater is safe to drink without purification. a.True or b. False");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer5 == "b")
{
scoreB = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N5
//n6
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("6. On a sailboat a sheet is: a. Ropes that controls rigging, b. A sail, c. A piece of bedding, d. A piece of paper.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer6 == "a")
{
scoreA = scoreB + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n6
//n7
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("7. On a sailboat a line is: a. Ropes that controls rigging, b. Ropes or cables that supports the rigging, c. A loose piece of general purpose rope, d. A rope used as a clothes line.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer7 == "b")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n7
//n8
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("8. What is a galley? a. A type of ship, b. A corridor on a ship, c. A ship’s kitchen, d. Both a and c.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer8 == "d")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n8
//n9
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("9. Salinity differs by ocean and locations, but on average sea water is what percent dissolved salt? a. 1%, b. 3.5%, c. 5.5%, d. 10%.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer9 == "b")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n9
//n10
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("10. North is 45° on a compass. a. True or b. False?");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer10 == "b")
{
scoreB = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n10
Console.ReadKey();
Console.WriteLine("Thanks for taking my quiz. Your Score is : " + scoreB);
}
static void ClassHeader()//Method 1
{
Console.WriteLine("Quiz Program");
}
}
}
I'm still very new at this so I'm trying to keep it very simple even if it is bloated. I'm posting the whole thing so y'all can see where I am as far as skill goes.
c#
New contributor
I'm making a quiz program, and have got it to a state (thanks to this forum) where it will run through the program and grade (somewhat) accurately. My loops are set up so that the user has infinite chances to answer each question. What I have been fighting with now is how to alter the program so 1 attempt is allowed, and the questions answered incorrectly will be asked again in a second round.
What I have been trying implement and failing at is to:
- have the second else condition of each of my if/else loops advance to the next question, mark the incorrect questions somehow so they will be repeated, and finally display the correct responses in the second iteration of questioning, and allow a second attempt for incorrect questions.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mark11QuizBasic
{
class Program
{
static void Main(string args)
{
int scoreA = 0;
int scoreB = 0;
int scoreC = scoreA + scoreB;
string answer1 = "d";
string answer2 = "a";
string answer3 = "c";
string answer4 = "d";
string answer5 = "b";
string answer6 = "a";
string answer7 = "b";
string answer8 = "d";
string answer9 = "b";
string answer10 = "b";
Program.ClassHeader();//Method1
//n1
Console.WriteLine("");
Console.WriteLine("Answers are case sensitive. Please enter answers in lower case. The best possible score is 10.");
Console.WriteLine("");
bool KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. Which math subject is critical in astral navigation? " +
"a. Probability and Statistics, b. Differential Calculus, c. Basic Algebra, d. Trigonometry.");
answer1 = Console.ReadLine();
Console.Clear();
if ((answer1 != "a") && (answer1 != "b") && (answer1 != "c") && (answer1 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer1 == "d")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n1
//N2
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. A sloop is a sailboat with one mast. a. True, b. False.");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer2 == "a")
{
scoreB = scoreB + scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n2
//N3
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("1. Port is which side of a ship? " +
"a. Right, b. Back, c. Left, d. Front.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer3 == "c")
{
scoreC = scoreB + 1;//score
Console.WriteLine("Correct! Score: " + scoreC);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N3
//N4
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("4. Starboard is which side of a ship? a. Front, b. Back, c. Left, d. Right.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer4 == "d")
{
scoreA = scoreC + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N4
//N5
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("5. Seawater is safe to drink without purification. a.True or b. False");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer5 == "b")
{
scoreB = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end N5
//n6
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("6. On a sailboat a sheet is: a. Ropes that controls rigging, b. A sail, c. A piece of bedding, d. A piece of paper.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer6 == "a")
{
scoreA = scoreB + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n6
//n7
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("7. On a sailboat a line is: a. Ropes that controls rigging, b. Ropes or cables that supports the rigging, c. A loose piece of general purpose rope, d. A rope used as a clothes line.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer7 == "b")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n7
//n8
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("8. What is a galley? a. A type of ship, b. A corridor on a ship, c. A ship’s kitchen, d. Both a and c.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer8 == "d")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n8
//n9
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("9. Salinity differs by ocean and locations, but on average sea water is what percent dissolved salt? a. 1%, b. 3.5%, c. 5.5%, d. 10%.");
answer3 = Console.ReadLine();
Console.Clear();
if ((answer3 != "a") && (answer3 != "b") && (answer3 != "c") && (answer3 != "d"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer9 == "b")
{
scoreA = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreA);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n9
//n10
KeepLooping = true;
while (KeepLooping)
{
Console.WriteLine("10. North is 45° on a compass. a. True or b. False?");
answer2 = Console.ReadLine();
Console.Clear();
if ((answer2 != "a") && (answer2 != "b"))
{
Console.WriteLine("INPUT INVALID");
}
else
{
if (answer10 == "b")
{
scoreB = scoreA + 1;//score
Console.WriteLine("Correct! Score: " + scoreB);
KeepLooping = false;
}
else
{
Console.WriteLine("Incorrect. Please try again.");
}
}
}//end n10
Console.ReadKey();
Console.WriteLine("Thanks for taking my quiz. Your Score is : " + scoreB);
}
static void ClassHeader()//Method 1
{
Console.WriteLine("Quiz Program");
}
}
}
I'm still very new at this so I'm trying to keep it very simple even if it is bloated. I'm posting the whole thing so y'all can see where I am as far as skill goes.
c#
c#
New contributor
New contributor
New contributor
asked 2 days ago
Kung_fu_carl
1
1
New contributor
New contributor
put on hold as off-topic by πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, 200_success, Jamal♦ 2 days ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, 200_success, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, 200_success, Jamal♦ 2 days ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, Sᴀᴍ Onᴇᴌᴀ, 200_success, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes