Hi, i was following This Math Quiz tutorial for Visual studio.
I hope it’s ok to publish my problem here since unity has C#.
My problem is that all the + , - and x works but my ÷ doesn’t seem to for some reason.
When the Game starts the Division’s stays at 0 so there is no answer.
Any idea why this is happening ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Math_Quiz
{
public partial class Form1 : Form
{
Random randomNumber = new Random();
int add1;
int add2;
int min1;
int min2;
int mult1;
int mult2;
int div1;
int div2;
int timeLeft;
public Form1()
{
InitializeComponent();
}
public void startTheQuiz()
{
add1 = randomNumber.Next(51);
add2 = randomNumber.Next(51);
plusLeftLabel.Text = add1.ToString();
plusRightLabel.Text = add2.ToString();
sum.Value = 0;
min1 = randomNumber.Next(1, 101);
min2 = randomNumber.Next(1, min1);
minusLeftLabel.Text = min1.ToString();
minusRightLabel.Text = min2.ToString();
minus.Value = 0;
mult1 = randomNumber.Next(2, 11);
mult2 = randomNumber.Next(2, 11);
timesLeftLabel.Text = mult1.ToString();
timesRightLabel.Text = mult2.ToString();
product.Value = 0;
div1 = randomNumber.Next(4, 11);
int temporaryQuotient = randomNumber.Next(4, 11);
div1 = div2 * temporaryQuotient;
dividedLeftLabel.Text = div1.ToString();
dividedRightLabel.Text = div2.ToString();
quotient.Value = 0;
}
private bool CheckTheAnswer()
{
if ((add1 + add2 == sum.Value)
(min1 - min2 == minus.Value)
(mult1 * mult2 == product.Value)
(div1 / div2 == quotient.Value))
return true;
else
return false;
}
private void startButton_Click(object sender, EventArgs e)
{
startTheQuiz();
startButton.Enabled = false;
timeLeft = 30;
timeLabel.Text = "30 Seconds";
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (CheckTheAnswer())
{
timer1.Stop();
MessageBox.Show("You got all the answers right!","Congratulations");
startButton.Enabled = true;
}
else if (timeLeft > 0)
{
timeLeft--;
This is propably the wrong place to ask this prblem, if any one knows a active C# forum to please share a link.
Appreciate any help.
~Wentzel