Advertisement
filip710

LV6 Z1

Dec 14th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace trokut
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         double a, b, c, opseg, povrsina, s;
  16.  
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         private void button1_Click(object sender, EventArgs e)
  23.         {
  24.             a = Convert.ToDouble(textBox_a_write.Text);
  25.             b = Convert.ToDouble(textBox_b_write.Text);
  26.             c = Convert.ToDouble(textBox_c_write.Text);
  27.             if (c == Math.Sqrt(a * a + b * b) && a == Math.Sqrt(c * c - b * b) && b == Math.Sqrt(c * c - a * a))
  28.                 MessageBox.Show("Trokut je pravokutan!");
  29.             else
  30.                 MessageBox.Show("Trokut nije pravokutan!");
  31.         }
  32.  
  33.         private void button_calculate_Click(object sender, EventArgs e)
  34.         {
  35.             try
  36.             {
  37.                 a = Convert.ToDouble(textBox_a_write.Text);
  38.                 b = Convert.ToDouble(textBox_b_write.Text);
  39.                 c = Convert.ToDouble(textBox_c_write.Text);
  40.  
  41.                 if ((a + b) > c && (a + c) > b && (b + c) > a)
  42.                 {
  43.                     opseg = a + b + c;
  44.                     s = (a + b + c) / 2;
  45.                     povrsina = Math.Sqrt(s * (s - a) * (s - b) * (s - c));
  46.  
  47.                     opseg = Math.Round(opseg, 2);
  48.                     povrsina = Math.Round(povrsina, 2);
  49.                     textBox_povrsina_write.Text = Convert.ToString(povrsina);
  50.                     textBox_opseg_write.Text = Convert.ToString(opseg);
  51.  
  52.                     label2_opseg.Text = Convert.ToString(opseg);
  53.                     label3_povrsina.Text = Convert.ToString(povrsina);
  54.                 }
  55.                 else
  56.                     MessageBox.Show("Unesene stranice ne tvore trokut.", "Greska!");
  57.  
  58.             }
  59.             catch
  60.             {
  61.                 MessageBox.Show("Upisite neke vrijednosti.", "Greska!");
  62.             }
  63.         }
  64.  
  65.         private void button1_izlaz_Click(object sender, EventArgs e)
  66.         {
  67.             Application.Exit();
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement