@kironroy/

cSharpQuiz

C#

No description

fork
loading
Files
  • main.cs
  • main.exe
  • notes.txt
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using System.Globalization;

namespace CSharpQuiz
{
    class Program
    {
        static void Main(string[] args)
        {
          
         // define variables 
            var cSharpwelcomePrompt = "Welcome to c++ quiz ";
            var correctAnswer = "Correct!\n";
            var wrongAnswer = "Wrong!\n";
            var quizAnswers = " Quiz answers:\n\n 1. 2002\n 2. Anders Hejlsberg\n 3. True, C# is  compiled";

            Console.WriteLine("What is your name");
            var nameInput = Console.ReadLine().Trim();
            var nameInputCaps = new CultureInfo("en-US").TextInfo.ToTitleCase(nameInput);
            BreakLine();
            Console.WriteLine($"Hello {nameInputCaps} {cSharpwelcomePrompt}");

            // question 1

          
            Console.WriteLine("1. When was C# created? (Type a year)");
            var quizQuestion1 = Console.ReadLine().Trim();

           
            if (quizQuestion1 == "2002") 
              {
                Console.WriteLine(correctAnswer);
              }
            else
                Console.WriteLine(wrongAnswer);
            BreakLine();

            // question 2

            
            Console.WriteLine("2. What is the first name of C#'s creator");
            var quizQuestion2 = Console.ReadLine().Trim().ToLower();
           

            if (quizQuestion2 == "anders")
              {
                Console.Write(correctAnswer);
                BreakLine();
              }
            else
                Console.WriteLine(wrongAnswer);
            BreakLine();


            // question 3

           
            Console.WriteLine("True or false: is C# compiled?, type true or false");
            var quizQuestion3 = Console.ReadLine().Trim().ToLower();
            if (quizQuestion3 == "true")
              {
                Console.WriteLine(correctAnswer);
              }
            else
                Console.WriteLine(wrongAnswer);
            BreakLine();

            Console.WriteLine(quizAnswers);

      } // main function ending bracket

     // breakline method
      private static void BreakLine()
        {
            Console.WriteLine();
        }

  } // class Program ending bracket
 
} // namespace ending bracket