Reputation: 91
I seem to have a problem with my equation, I want to solve a problem like this Z= A/(C*B)
where A
is equal to F/G(i.e A=F/G)
but it seems I'm getting the same answer when I calculate A
and Z
no matter how many times I change the values my program outputs A
and Z
to be equal which is mathematically not true because if I say A=4/2
I get a 2
and Z = 2/(8*1)
is supposed to be 0.25
think what am I missing out??
my code
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 trafic_model
{
public partial class Form1 : Form
{
double a = 0, b = 0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//С1
a = Convert.ToDouble(textBox1.Text) / Convert.ToDouble(textBox2.Text);
label3.Text = "C1 = " + a.ToString() + " Мбит/с.";
//end of c1
//N1
z = (a / (Convert.ToDouble(textBox3.Text) * Convert.ToDouble(textBox5.Text)));
label6.Text = "N1 = " + a.ToString() ;
//
}
}
Upvotes: 0
Views: 128
Reputation: 3816
The problem is that you write a.ToString() into both text boxes and never write z at all..
Change
label6.Text = "N1 = " + a.ToString() ;
To
label6.Text = "N1 = " + z.ToString() ;
Upvotes: 0
Reputation: 4643
z = (a / (Convert.ToDouble(textBox3.Text) * Convert.ToDouble(textBox5.Text)));
label6.Text = "N1 = " + a.ToString() ;
Do you mean that label6 should be "N1 = " + z.ToString() ;
?
Upvotes: 3
Reputation: 75306
Just guess you are using the wrong variable, it should be z
instead of a
in below line:
label6.Text = "N1 = " + z.ToString() ;
Upvotes: 4