Question
I'm using C#, trying to get this to loop the incorrect answers to give a second attempt and then give a score. using System; namespace
I'm using C#, trying to get this to loop the incorrect answers to give a second attempt and then give a score.
using System;
namespace FileName { class Program { public static void Main(string[] args) { String name = "My Name"; String courseName = "Course Name"; String assignmentName = "Assignment Name"; int answer; Console.WriteLine("Name: " + name); Console.WriteLine("Course Name: " + courseName); Console.WriteLine("Assignment Name: " + assignmentName); //used as a header to identify me, the course, and the assignement
Console.WriteLine(" Question 1: The blue whale is the largest mammal."); Console.WriteLine("1 = True 2 = False"); //Question 1 and answers
Console.WriteLine("Choose the correct answer"); //prompts user to answer question
answer = Convert.ToInt32(Console.ReadLine()); String correct_or_wrong = 1 == answer ? "Correct" : "Incorrect"; Console.WriteLine(correct_or_wrong); //lets user know if they were correct or incorrect
Console.WriteLine(" Question 2: What is the longest river in the world?"); Console.WriteLine("1 = Amazon River 2 = Nile River 3 = Congo River 4 = Yellow River"); //Question 2 and answers
Console.WriteLine("Choose the correct answer"); //prompts user to answer question
answer = Convert.ToInt32(Console.ReadLine()); correct_or_wrong = 2 == answer ? "Correct" : "Incorrect"; Console.WriteLine(correct_or_wrong); //lets user know if they were correct or incorrect
} } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started