Question
Write a program that will ask the user for their name. If the user does not input anything, display a warning before continuing. The program
Write a program that will ask the user for their name. If the user does not input anything, display a warning before continuing. The program will then ask the user whether they want to have an addition, subtraction, multiplication, or division problem. Once the user indicates their choice, the program will display 2 randomly generated whole numbers from 1 to 9 in a math problem matching the users choice.
Example: user selects addition, the equation presented is:
(random number from 1 to 9) + (random number from 1 to 9)
The user will then input an answer as a whole number. If the answer they entered is not a whole number, tell the user their input is invalid and end the program. If the input is valid, check to see if it is the correct answer. If correct, congratulate the user by name. If incorrect, output the correct answer.
Tasks
- The program needs to contain the following
- A comment header containing your name and a brief description of the program
- At least 5 comments besides the comment header explaining what your code does
- A string variable that captures the users name
- A way to validate user input to determine if they entered an empty string
- Warn the user if they enter an empty string
- Continue the program after warning the user
- A prompt for what type of quiz the user wants
- Display of a quiz matching the type the user requested
- Note: to avoid getting the same random number. Create one Random object and call .Next with it twice.
- A prompt for an answer in the form of a whole number
- A message if the user enters an invalid number
- Do not check the users answer if their input is invalid
- If input is valid:
- Check the answer
- If the answer is correct, congratulate the user by name
- If incorrect, output the correct answer
- A message if the user enters an invalid number
- Upload a completed .cs file onto the Assignment 4 submission folder and a word document containing the following six (6) screenshots:
- The warning displayed when the user enters a blank value for the name
- One test run for each equation with valid input
- Answer 2 quizzes correctly
- Answer 2 quizzes incorrectly
- One test run with invalid input
Please code in C#
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