|
c# |
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(textBox1.Text);
int b = Convert.ToInt32(textBox2.Text);
int c = Convert.ToInt32(textBox3.Text);
double x = aritmetikortalama(a, b, c);
double y = geometrikortalama(a, b, c);
double z = harmonikortalama(a, b, c);
int d = 0;
if (checkBox1.Checked==true)
{
listBox1.Items.Add("aritmetikortalama" + x);
d = d + 1;
}
if (checkBox2.Checked==true)
{
listBox1.Items.Add("geometrikortalama" + y);
d = d + 1;
}
if (checkBox3.Checked==true)
{
listBox1.Items.Add("harmonikortalama" + z);
d = d + 1;
}
listBox1.Items.Add(d);
}
double aritmetikortalama(int x1, int x2, int x3)
{
return (x1 + x2 + x3) / 3.0;
}
double geometrikortalama(int x1, int x2, int x3)
{
double go;
int carpım;
carpım = x1 * x2 * x3;
go = Math.Pow(carpım, 1 / 3.0);
return go;
}
double harmonikortalama(int x1, int x2, int x3)
{
return 3.0 / ((1.0 / x1) + (1.0 / x2) + (1.0 / x3));
}
}
}
0 yorum :
Yorum Gönder