Srxon05

praksa 1

Jun 7th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 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 WindowsFormsApplication1
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  21.         {
  22.  
  23.         }
  24.  
  25.         private void button1_Click(object sender, EventArgs e)
  26.         {
  27.             int a;
  28.             if (!int.TryParse(tb1.Text, out a))
  29.             {
  30.                 MessageBox.Show("Greska! pogresan unos prvog broja");
  31.             }
  32.             else
  33.             {
  34.             int b;
  35.            
  36.                 if (!int.TryParse(tb2.Text, out b))
  37.             {
  38.                 MessageBox.Show("Greska! pogresan unos prvog broja");
  39.             }
  40.             else{
  41.                 if (cb1.SelectedItem == "+")
  42.                 {
  43.                     tb3.Text = Convert.ToString(a + b);
  44.                 }
  45.                 else if (cb1.SelectedItem == "-")
  46.                 {
  47.                     tb3.Text = Convert.ToString(a - b);
  48.                 }
  49.                 else if (cb1.SelectedItem == "*")
  50.                 {
  51.                     tb3.Text = Convert.ToString(a * b);
  52.                 }
  53.                 else if (cb1.SelectedItem == "/")
  54.                 {
  55.                     tb3.Text = Convert.ToString(a / b);
  56.                 }
  57.                 else
  58.                 {
  59.                     MessageBox.Show("Niste odabrali operaciju");
  60.                 }
  61.                 }}
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment