Using C#
Create an instance of the “TestQuestion” class in your “main” method. Allow the user to enter the test question and its answer, if they want to. If they do not, then continue by creating a default question and answer. Please use the constructor methods here. Then, using the “ToString” or “__str__” method, have it print out those variables as described above.
Lastly, call the “CheckAnswer” method and allow the user to continue attempting to answer the question until they are correct. If they are correct, the method should work as above and allow them to enter a new question and answer. You may either terminate the program at this point (if the user types “quit”) or allow for an infinite series of trivia games.
Example:
Please enter a test question (or just hit enter to skip): “What is your favorite color?”
Please enter the answer to that question (or just hit enter to skip): “Blue”
Your question was: “What is your favorite color?” and your answer was: “Blue”
Please enter your answer to the test question: “Red”
I’m sorry, you were incorrect and have not dethroned the previous champion. Please enter another answer to the test question: “Blue”
You are the new champion. Claim your prize by setting a new more difficult question: “What is the airspeed velocity of an unladen Swallow?”
And the answer to that question: “24 miles per hour.”
Your question was: “What is the airspeed velocity of an unladen Swallow?” and your answer was: “24 miles per hour.”
…. (It should continue asking for the correct answer. Otherwise it should end here if the user types “quit”.)
Example using Default Question and Answer:
Please enter a test question (or just hit enter to skip): “”
Please enter the answer to that question (or just hit enter to skip): “”
Your question was: “Find the value of x in 4 = x ^ 2” and your answer was: “2”
Please enter your answer to the test question: “16”
I’m sorry, you were incorrect and have not dethroned the previous champion. Please enter another answer to the test question: “4”
You are the new champion. Claim your prize by setting a new more difficult question: “What is the airspeed velocity of an unladen Swallow?”
Please enter the answer to that question: “24 miles per hour.”
Your question was: “What is the airspeed velocity of an unladen Swallow?” and your answer was: “24 miles per hour.”
…. (It should continue on like that, if using a loop. Otherwise it should end here.)
In the question it was asked to write a program representing a test question and answers also given some requirements to know the details about the program.
So below we have written the python program:
class TestQuestion:
""" TestQuestion class """
def __init__(self, quest="Find the value of x in 4 = x ^ 2",
ans="2"):
""" Constructor """
self.question = quest
self.answer = ans
def getQuestion(self):
""" Returns question """
return self.question
def getAnswer(self):
""" Returns answer """
return self.answer
def CheckAnswer(userAns, tObj):
""" Checks answer """
while True:
if userAns==tObj.getAnswer():
return
else:
userAns = input("I'm sorry, you were incorrect and have not
dethroned the previous champion. Please enter another answer to the
test question: ")
def main():
""" Main method """
# Reading input from user
questC = input("Please enter a test question (or just hit enter to
skip): ")
while True:
ansC = input("Please enter the answer to that question (or just hit
enter to skip): ")
# Checking quest and ans
if questC=="" and ansC=="":
tObj = TestQuestion()
elif questC=="" and ansC!="":
tObj = TestQuestion(ans=ansC)
elif questC!="" and ansC=="":
tObj = TestQuestion(quest=questC)
else:
tObj = TestQuestion(questC, ansC)
print("Your question was: \"" + tObj.getQuestion() + "\" and your
answer was: \"" + tObj.getAnswer() + "\"")
# Reading answer
userAns = input("Please enter your answer to the test question:
")
# Checking Answer
CheckAnswer(userAns, tObj)
# Reading input from user
questC = input("You are the new champion. Claim your prize by
setting a new more difficult question (Enter quit to exit):
")
if questC.lower() == "quit":
return
# Calling main function
main()
___________________________________________________________________________________________________
Sample Run:
Here we can have a clear view of the screen.

Hence we have cleared all the given requirements in the question for the python program.
Using C# Create an instance of the “TestQuestion” class in your “main” method. Allow the user...
Urgent must be done in C# create an instance of the “ testquestion” class in your main method. allow the uswr to enter the teat question and its answer, it they want to. if they do not, then continue by creating a default queatuon and answer. please use the constructor methods here. Then, using the “tostring or _str_method, have it print out those variables as decribed above. call the “check answer” method and allow the user to continue attempting to...
IN JAVA Create the “MathTest” class. It will have two class variables: 1) a question and 2) the answer to that question. Please create an accessor and mutator method for both of those variables, without which we would not be able to see or change the question or the answer. There should be a constructor method. We will also have a “ToString” method, which will print the question followed by its answer. The constructor method has two parameters to allow...
Create a program in Python that will allow the user to enter a temperature in Fahrenheit which will then be converted to degrees Celsius. The program will keep asking the user for a Fahrenheit temperature until the user enters Q to quit. After each conversion the program needs to print out the degrees Celsius. The input prompts for this problem need to look like the following: Degrees Fahrenheit: Continue: For these input prompts watch the capitalization and spacing. There are...
Lab: User login system (python) Create a user login system. Your code should do the following: 1.Load your user database from “UD.txt” (USE THE EXACT FILE NAME, file is given in the folder) 2.Display “Login or create a new user? Select L to login, select C to create new user.” 3. If wrong selection is entered, take the user back to step 2. 4. If the user entered “L”, display “Please enter your user name and hit enter” 5. Check...
Using C# Create a “Main” method that will take user input one line at a time until they enter the phrase “done”. Store each line entered into an ArrayList, so that one element of the ArrayList is one line of user input. You do NOT need to write your own ArrayList class, please use the standard library implementation of an ArrayList. After the user finishes typing in input, ask the user for a location and file name. Save the contents...
C++ please no arrays! Create a program that will allow the user to enter up to 50 whole values and determine the number of values entered, how many of the values were odd and how many of the values were even. Your code should contain 2 functions, a main function and a function to enter the numbers enter and count the values. Your main function should be a driver program that will call another function to count the total number...
Write a C++ program to allow the user to create a test bank of questions. The program should first ask the user how many questions he or she wishes to create. This quantity will be the first line in the test bank. The user should now be prompted for all information for each question, and then that question is written out to the test bank in the exact format specified in the Phase 2 Individual Project. For each question, the...
C Code Create a tool in which a user can enter a string (up to 25 characters) and choose how they wish to manipulate the string from a menu your program will display (see the run-through). The program will continue to ask for commands until the user enters the “quit” command. The commands are: • “Replace All” If a user types “replace all” using ANY sort of capitalization, your program will prompt the user to enter the character to change...
Need help with code in C# Create an application that reads a file named Accounts.txt. Your application should load the file and display back the results. The application should allow the user to enter additional entries and save them back to the same file. The CSV file should contain the following fields: AccountName, InvoiceDate, DueDate, AmountDue If the CSV file contains invalid data you want to inform the user which row contained bad data. Below is an example of what...
import java.util.Scanner; public class MPGMain { public static void main(String[] args) { Scanner input = new Scanner(System.in); Mileage mileage = new Mileage(); System.out.println("Enter your miles: "); mileage.setMiles(input.nextDouble()); System.out.println("Enter your gallons: "); mileage.setGallons(input.nextDouble()); System.out.printf("MPG : %.2f",mileage.getMPG()); } } public class Mileage { private double miles; private double gallons; public double getMiles()...