الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

[تنبيه : عنوان غير مناسب]مساعده فى السى شارب

بدأه TheSniper102 في 14 أبريل 2011 · 1 رد · 385 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

hi

i'm looking for doing a programe that solve this equation y=m*x+b

where m is the slope and equal m=(y2-y1)/(x2-x1)

and b is the intersect with y axssis

now i wanna to enter 4 vlaues x1 ,x2,y1,y2 in textbox to clalculate the m and b

and this is easey now what i wanna and the problem is

according to x vlaue calculate the y vlaue where x is the numbers in rang from x1 to x2 and print the result in richtext box

any soulations??????????

here is my code please correct it 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 SniperDrawing
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox5_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            int x1, y1, x2, y2, m, b, y;

            x1 = int.Parse(textBox1.Text);
            y1 = int.Parse(textBox2.Text);
            x2 = int.Parse(textBox3.Text);
            y2 = int.Parse(textBox4.Text);
            m = (y2 - y1) / (x2 - x1);
            b = y1 - m * x1;
            int x = x1;
           while ( x <= x2)
            {
               y=m*x1+b;

                    richTextBox1.Text = Convert.ToString(y);
                    for (int i = x1; i<= x2; i++)
                    {
                        richTextBox1.AppendText(Convert.ToString(y));
                    }
                    x1 = x1 + 1;

            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            MessageBox.Show("Thanks trying my programe");
        }





    }
}
#2

Hello TheSniper

Check this 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 ArabTeam2000_Solution
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public void textBox3_TextChanged(object sender, EventArgs e)
{

}

public void button1_Click(object sender, EventArgs e)
{
int x1, x2, y1, y2, b, m, y;
x1 = Convert.ToInt32(txt_x1.Text);
x2 = Convert.ToInt32(txt_x2.Text);

y1 = Convert.ToInt32(txt_y1.Text);
y2 = Convert.ToInt32(txt_y2.Text);

b = Convert.ToInt32(txt_varB.Text);

int xx = x2 - x1;
int yy = y2 - y1;

m = yy / xx;
txt_m.Text = m.ToString();

/*Till now , Bro. Sinper u did well , ur problems starts here
*/
if (x2 > x1)
{
for (int x = x1; x <= x2; x++)
{
y = m * x + b;
txt_finalResault.Items.Add(y.ToString());
}
}

}

public void button2_Click(object sender, EventArgs e)
{

}

private void txt_finalResault_SelectedIndexChanged(object sender, EventArgs e)
{

}
}
}

now , I want from you 3 things to make your homework a good one

1- check and issue that x2=x1 or y2=y2 , here's a division on ZERO exception it's a big mathematical fault

2- I don't prefer integer values for such mathematical programs the slope couldn't be 3.5 !! well it's easy

3-I made the output in listbox , if u want to put it in a richtext box , u need to make it print line by line by "/n" it's like making Enter

why did u declared a variable called x , and x=x1 ? then u used While Loop and For loop just to fill ur Richtextbox ? ?



About my code :
make a window form
every thing starts with txt is a text box txt_x1 , txt_x2 .... are text boxes
button1 is the calculation button
txt_finalResault is the list box

I hope that I helped u , any questions am ready

تم تعديل هذه المشاركة بواسطة Zouhir في 14 أبريل 2011 في 12:08

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…