0% found this document useful (0 votes)
26 views3 pages

True False Quiz (Programacion)

The document describes a program that asks the user a series of true/false questions, stores their responses, and then scores their answers against the correct answers. The program contains an array of questions, an array to store the user's responses, and an array of correct answers. It loops through asking each question, validating the user's input, storing their response, and then at the end scores their answers against the correct answers and displays the result.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

True False Quiz (Programacion)

The document describes a program that asks the user a series of true/false questions, stores their responses, and then scores their answers against the correct answers. The program contains an array of questions, an array to store the user's responses, and an array of correct answers. It loops through asking each question, validating the user's input, storing their response, and then at the end scores their answers against the correct answers and displays the result.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

using System;

using System.Threading;

namespace ejerciciosvariados

class Program

static string[] numbers = new string[10];

static void Main(string[] args)

// Do not edit these lines

Console.WriteLine("Welcome to 'True or False?'\nPress Enter to begin:");

string entry = Console.ReadLine();

// Type your code below

string[] questions = { "Do you like me?", "Would you like to go out with
me?", "Can I get your number?" };

bool[] correctAnswers = { true, true, true };

bool[] responses = new bool[questions.Length];

if (questions.Length != correctAnswers.Length)

Console.WriteLine("questions array and correctAnswers array do not share


the same length");

}
int askingIndex = 0;

foreach (string i in questions)

bool isBool = false;

string input;

bool inputBool;

while (!isBool)

Console.WriteLine(i);

Console.WriteLine("True or false?");

input = Console.ReadLine();

isBool = Boolean.TryParse(input, out inputBool);

if (!isBool)

Console.WriteLine("Please respond with 'true' or 'false'");

responses[askingIndex] = inputBool;

askingIndex++;
}

int scoringIndex = 0;

int score = 0;

foreach (bool i in correctAnswers)

bool response = responses[scoringIndex];

Console.WriteLine(scoringIndex+1 +" Input: "+ response +" | "+"Answer:


"+i);

if (i==response)

score++;

scoringIndex++;

Console.WriteLine($"You got {score} out of {questions.Length} correct.");

Console.ReadKey();

You might also like