Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am doing a math quiz game project for kids in primary school, in C#, using visual stdio 2017. How do I do a divison

I am doing a math quiz game project for kids in primary school, in C#, using visual stdio 2017. How do I do a divison using random numbers so it devides by positive even numbers only. Can you modify my code below to divided random numbers, so the first number is always higher than the divisor and the result is a positive interger with no remainder. I have just started learning c#. Can you modify the code below so that the division answer does not leave a remainder.

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

namespace AssignmentQuiz { public partial class Form8 : Form { public Form8() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { Form1 newForm = new Form1(); newForm.Show(); this.Hide(); } int num1, num2, num3, num4, num5, num6;

private void button2_Click(object sender, EventArgs e) { int answer1 = Convert.ToInt32(textBox1.Text); int answer2 = Convert.ToInt32(textBox2.Text); int answer3 = Convert.ToInt32(textBox3.Text);

if (((num1 / num2 == answer1) && (num3 / num4 == answer2) && (num5 / num6 == answer3))) { MessageBox.Show("WELL DONE. ALL ANSWERS CORRECT!!");

Form11 newForm = new Form11(); newForm.Show(); this.Hide(); } else { MessageBox.Show("SORRY. INCORRECT ANSWER"); } } private void Button1_Click_1(object sender, EventArgs e) { System.Random random = new System.Random();

int min = 5; int max = 15; num1 = random.Next(min / 2, max / 2) * 2; label1.Text = num1.ToString();

int mn = 2; int mx = 6; num2 = random.Next(mn / 2, mx / 2) * 2; label3.Text = num2.ToString();

int mmn = 5; int mxm = 20; num3 = random.Next(mmn / 2, mxm / 2) * 4; label5.Text = num3.ToString();

int mnm = 2; int mxn = 6; num4 = random.Next(mnm / 2, mxn / 2) * 4; label7.Text = num4.ToString();

int nmn = 5; int mxx = 25; num5 = random.Next(nmn / 2, mxx / 2) * 6; label9.Text = num5.ToString();

int m = 2; int n = 6; num6 = random.Next(m / 2, n / 2) * 6; label11.Text = num6.ToString(); }

} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

What is social media? Explain how it can be used for training.

Answered: 1 week ago

Question

thanks Which structure is different from the following? A B C D

Answered: 1 week ago