Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 trokut
- {
- public partial class Form1 : Form
- {
- double a, b, c, opseg, povrsina, s;
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- a = Convert.ToDouble(textBox_a_write.Text);
- b = Convert.ToDouble(textBox_b_write.Text);
- c = Convert.ToDouble(textBox_c_write.Text);
- if (c == Math.Sqrt(a * a + b * b) && a == Math.Sqrt(c * c - b * b) && b == Math.Sqrt(c * c - a * a))
- MessageBox.Show("Trokut je pravokutan!");
- else
- MessageBox.Show("Trokut nije pravokutan!");
- }
- private void button_calculate_Click(object sender, EventArgs e)
- {
- try
- {
- a = Convert.ToDouble(textBox_a_write.Text);
- b = Convert.ToDouble(textBox_b_write.Text);
- c = Convert.ToDouble(textBox_c_write.Text);
- if ((a + b) > c && (a + c) > b && (b + c) > a)
- {
- opseg = a + b + c;
- s = (a + b + c) / 2;
- povrsina = Math.Sqrt(s * (s - a) * (s - b) * (s - c));
- opseg = Math.Round(opseg, 2);
- povrsina = Math.Round(povrsina, 2);
- textBox_povrsina_write.Text = Convert.ToString(povrsina);
- textBox_opseg_write.Text = Convert.ToString(opseg);
- label2_opseg.Text = Convert.ToString(opseg);
- label3_povrsina.Text = Convert.ToString(povrsina);
- }
- else
- MessageBox.Show("Unesene stranice ne tvore trokut.", "Greska!");
- }
- catch
- {
- MessageBox.Show("Upisite neke vrijednosti.", "Greska!");
- }
- }
- private void button1_izlaz_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement