Question
using c# visual studio thanks 7.39 (Computer-Assisted Instruction) The use of computers in education is referred to as computer-assisted instruction ( CAI ). Write a
using c# visual studio thanks
7.39 (Computer-Assisted Instruction) The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary-school student learn multiplication. Use a Random object to produce two positive one-digit integers. The program should then prompt the user with a question, such as
How much is 6 times 7?
The student then inputs the answer. Next, the program checks the students answer. If it is correct, display the message "Very good!" and ask another multiplication question. If the answer is wrong, display the message "No. Please try again." and let the student try the same question repeatedly until the student gets it right. A separate method should be used to generate each new question. This method should be called once when the app begins execution and each time the user answers the question correctly.
here is the code that I have but for some reason, I keep getting the same question (0 * 0) can you help me figure out what I did wrong or do this problem tnx
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace P739 { class P739 {
private static Random random = new Random(); private static int randomNumber1 = 0; private static int randomNuber2 = 0; private static int multiplicationResult = 0; private static bool isNeedToShowQuestionAgain = false;
private static int RandomNumber (int min, int max) { return random.Next(min,max); } private static void GenerateQuestion (bool isNeedToShowQuestion) { if (!isNeedToShowQuestionAgain) PrintQuestion(); }
private static void PrintQuestion() { Console.WriteLine(string.Format("How much is {0} times {1}?", randomNumber1, randomNuber2)); }
static void Main() { while (true) { int userInput=0; GenerateQuestion(isNeedToShowQuestionAgain); try { userInput = Convert.ToInt32(Console.ReadLine()); } catch { } if (userInput == multiplicationResult) { Console.WriteLine("very good! your answer is correct."); isNeedToShowQuestionAgain = false; } else { Console.WriteLine("No.Please try again."); isNeedToShowQuestionAgain = true; } }
} } }
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