|
-
October 19th, 2008, 12:28 PM
#1
computing slope, please help
Hello, I am doing an assignment, I need to get a program that figures out slope. I am almost done, I am having writing the last part. I need to divide the numerator by the denominator. I have copied the code below. Thanks
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
int y1, y2, numerator;
int x1, x2, denominator;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
y2 = int.Parse(textBox1.Text);
y1 = int.Parse(textBox2.Text);
numerator = y2 - y1;
textBox3.Text = numerator.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
x2 = int.Parse(textBox4.Text);
x1 = int.Parse(textBox5.Text);
denominator = x2 - x1;
textBox6.Text = denominator.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
textBox7.Text = textBox3.Text / textBox6.Text.ToString();
}
}
}
-
October 19th, 2008, 01:02 PM
#2
Re: computing slope, please help
You're almost there. Do it like you did the other
Code:
textBox7.Text = (int.Parse(textBox3.Text) / int.Parse(textBox6.Text)).ToString();
-
October 19th, 2008, 01:34 PM
#3
Re: computing slope, please help
ok, i run the program, but for some reason it isnt giving me the correct values of x2 - x1. I looked at the code everything looks right. The division works right, y2-y1 gives the right value, but for some odd reason x2-x1 doesnt give the right answer. What can i do to fix this?
-
October 19th, 2008, 01:46 PM
#4
Re: computing slope, please help
Are you referring to the proper text boxes? Set a breakpoint and run it in the debugger and check that you get the values you expect to get.
Also, I just realized that I rushed my last answer a bit to much. You probably want to use double for the slope calculation.
-
October 19th, 2008, 01:52 PM
#5
Re: computing slope, please help
ok i re did the porject, it works now. Thanks SMA
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|