Skip to content

Instantly share code, notes, and snippets.

@codecademydev codecademydev/Program.cs Secret
Created Sep 5, 2019

Embed
What would you like to do?
Codecademy export
using System;
namespace TrueOrFalse
{
class Program
{
static void Main(string[] args)
{
// Do not edit these lines
Console.WriteLine("Welcome to 'True or False?'\nPress any key to begin:");
string entry = Console.ReadLine();
Tools.SetUpInputStream(entry);
// Type your code below
string [] questions = {"the sky is blue?", "there are seven days in a week", "girls can't fart"};
bool [] answers = {true, true, false };
bool [] responses = new bool[3];
if (questions.Length != answers.Length)
{
Console.WriteLine("questions and answers do not match");
}
int askingIndex = 0;
foreach (string question in questions)
{
string input;
bool replyAsBool;
bool isBool;
{Console.WriteLine($" {questions[0]}. Please respond true or false");
Console.ReadLine();
string reply = Console.ReadLine();
}
{Console.WriteLine($" {questions[1]}. Please respond true or false");
Console.ReadLine();
string reply2 = Console.ReadLine();
}
{Console.WriteLine($" {questions[2]}. Please respond true or false");
Console.ReadLine();
string reply3 = Console.ReadLine();
}
isBool = Boolean.TryParse(reply, out replyAsBool);
}
}
}
}
}
@bassdb1

This comment has been minimized.

Copy link

bassdb1 commented Sep 25, 2019

I would try this.
//Check to see that both arrays have the same number of elements

  if (questions.Length != answers.Length)
  {
    Console.WriteLine("Warning : The question and answer arrays are not equal");
  }
  
  int askingIndex = 0;
  
   use a foreach loop to go through each item in the array
  
  foreach (string question in questions)
  {
    string input;
    bool isBool;
    bool inputBool;

    Console.WriteLine(question);
    Console.WriteLine("True or False?");
    input = Console.ReadLine();
    
   isBool = public static bool TryParse(string input, out inputBool);
   isBool = Boolean.TryParse(input, out inputBool);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.