Advertisement
Guest User

SlojnaLihvaKontrolno

a guest
Nov 12th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.21 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 WindowsFormsApplication3
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void button1_Click(object sender, EventArgs e)
  21.         {
  22.             double A, P, r, n, t;
  23.             try
  24.             {
  25.               P =  Double.Parse(textBox1.Text);
  26.               r = Double.Parse(textBox2.Text);
  27.               n = Double.Parse(textBox3.Text);
  28.               t = Double.Parse(textBox4.Text);
  29.               if (P < 0&&n<0&&t<0&&r<0)
  30.               {
  31.                   MessageBox.Show("Грешка");
  32.                   textBox1.Clear();
  33.                   textBox2.Clear();
  34.                   textBox3.Clear();
  35.                   textBox4.Clear();
  36.                   textBox5.Clear();
  37.               }
  38.               if (radioButton1.Checked)
  39.               {
  40.                   A = P * Math.Pow((1 + r / n), n * t );
  41.                   textBox1.Text = P.ToString();
  42.                   textBox2.Text = r.ToString();
  43.                   textBox3.Text = n.ToString();
  44.                   textBox4.Text = t.ToString();
  45.                   textBox5.Text = A.ToString();
  46.               }
  47.               else
  48.               {
  49.                  if (radioButton2.Checked)
  50.               {
  51.                   A = Double.Parse(textBox5.Text);
  52.                   A = P * (1 + r * t);
  53.                   textBox1.Text = P.ToString();
  54.                   textBox2.Text = r.ToString();
  55.                   textBox3.Text = n.ToString();
  56.                   textBox4.Text = t.ToString();
  57.                   textBox5.Text = A.ToString();
  58.  
  59.                  }
  60.               }
  61.             }
  62.             catch
  63.             {
  64.                 MessageBox.Show("Въведете коректни стойности");
  65.                 textBox1.Clear();
  66.                 textBox2.Clear();
  67.                 textBox3.Clear();
  68.                 textBox4.Clear();
  69.                 textBox5.Clear();
  70.             }
  71.            
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement