You are on page 1of 1

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsControlLibrary3
{
public partial class UserControl1: UserControl
{
public UserControl1()
{
InitializeComponent();
}

private void Button1_Click(object sender, EventArgs e)


{
listBox1.Items.Clear();
double a = Convert.ToDouble(textBox1.Text);
double b = Convert.ToDouble(textBox2.Text);
if (radioButton1.Checked)
{
double korak = Convert.ToDouble(textBox3.Text);
for (double x = a; x <= b; x += korak)
{
if (x * x - 4 * x - 6 >= 0 && 17 - 4 * x != 0)
{
double y = (2 + Math.Sqrt(x * x - 4 * x - 6) / 17 - x * 4);
listBox1.Items.Add("f(" + x.ToString("0.00") + ")=" + y.ToString("0.00"));
}
else
listBox1.Items.Add("Za " + x.ToString("0.00") + " nije definisana");
}
}
else
{
listBox1.Items.Clear();
}

if (radioButton2.Checked)
{
int broj = Convert.ToInt32(textBox3.Text);
double x = a, korak = (b - a) / (broj - 1);
for (int i = 0; i < broj; i++, x += korak)
{
if (x * x - x * 4 - 6 >= 0 && 17 - 4 * x != 0)
{
double y = (2 + Math.Sqrt(x * x - 4 + x - 6)) / (17 - 4 * x);
listBox1.Items.Add("f(" + x.ToString("0.00") + ")= " + y.ToString("0.00"));
}
else
listBox1.Items.Add("Za " + x.ToString("0.00") + "nije definisana");
}
}
else
{
listBox1.Items.Clear();
}
}
}
}

You might also like