O
O
Odyvanchik2018-04-16 12:28:13
Windows Forms
Odyvanchik, 2018-04-16 12:28:13

Why doesn't it display the calculations in lael5?

5ad46c87b33fe884106888.jpeg
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 BodyState
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int m = Convert.ToInt32(textBox2.Text);
int h = Convert.ToInt32(textBox3.Text);
int x = m / (h*h);
if ((radioButton1.Checked == true) && (radioButton2.Checked == true))
{
if (x <= 20)
{
label5.Text = string.Format("You are underweight.");
}
if ((x >= 20 && x <= 25))
{
label5.Text = string.Format("Don't worry, your weight is normal and in harmony with the world.");
}
if ((x >= 25) && (x <= 30))
{
label5.Text = string.Format("You should start taking care of your body; you are slightly overweight. Further accumulation of fat increases the risk of various diseases and deterioration in overall health.");
}
if ((x >= 30) && (x <= 35))
{
label5.Text = string.Format("You are clearly obese, so you should do your best to reduce this figure.");
}
if (x >= 30)
{
label5.Text = string.Format("You're obese; it's time to sound the alarm and start actively working on getting back in shape.");
}
}
private void helpToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Fill in the suggested empty fields. Enter values ​​as integers. Specify height in centimeters.", "Help",
MessageBoxButtons.OKCancel);
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void button2_Click(object sender, EventArgs e)
{
textBox2.Clear();
textBox3.Clear();
label5.Text = "";
}
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
devilya, 2018-04-16
@devilya

if ((radioButton1.Checked == true) && (radioButton2.Checked == true))
The condition should at least be changed to OR. Such a combination is theoretically not possible (M and F sex).
And in general, apparently, the selected gender is not used in the calculation, so specifically in this case, you only need to check whether at least one of the proposed options (M OR F) is selected.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question