Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 1. Napravite aplikaciju znanstveni kalkulator koja će imati funkcionalnost
- znanstvenog kalkulatora, odnosno implementirati osnovne (+,-,*,/) i barem 5
- naprednih (sin, cos, log, sqrt...) operacija.*/
- 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 LV6
- {
- public partial class form_kalkulator : Form
- {
- double PrviBr;
- string Operacija;
- public form_kalkulator()
- {
- InitializeComponent();
- }
- private void button_br1_Click(object sender, EventArgs e)
- {
- if (textBox_display.Text == "0" && textBox_display.Text != null)
- {
- textBox_display.Text = "1";
- }
- else
- {
- textBox_display.Text = textBox_display.Text + "1";
- }
- }
- private void button_br2_Click(object sender, EventArgs e)
- {
- if (textBox_display.Text == "0" && textBox_display.Text != null)
- {
- textBox_display.Text = "2";
- }
- else
- {
- textBox_display.Text = textBox_display.Text + "2";
- }
- }
- private void button_br3_Click(object sender, EventArgs e)
- {
- if (textBox_display.Text == "0" && textBox_display.Text != null)
- {
- textBox_display.Text = "3";
- }
- else
- {
- textBox_display.Text = textBox_display.Text + "3";
- }
- }
- private void button_br4_Click(object sender, EventArgs e)
- {
- if (textBox_display.Text == "0" && textBox_display.Text != null)
- {
- textBox_display.Text = "4";
- }
- else
- {
- textBox_display.Text = textBox_display.Text + "4";
- }
- }
- private void button_br5_Click(object sender, EventArgs e)
- {
- if (textBox_display.Text == "0" && textBox_display.Text != null)
- {
- textBox_display.Text = "5";
- }
- else
- {
- textBox_display.Text = textBox_display.Text + "5";
- }
- }
- private void button_br6_Click(object sender, EventArgs e)
- {
- if (textBox_display.Text == "0" && textBox_display.Text != null)
- {
- textBox_display.Text = "6";
- }
- else
- {
- textBox_display.Text = textBox_display.Text + "6";
- }
- }
- private void button_br7_Click(object sender, EventArgs e)
- {
- if (textBox_display.Text == "0" && textBox_display.Text != null)
- {
- textBox_display.Text = "7";
- }
- else
- {
- textBox_display.Text = textBox_display.Text + "7";
- }
- }
- private void button_br8_Click(object sender, EventArgs e)
- {
- if (textBox_display.Text == "0" && textBox_display.Text != null)
- {
- textBox_display.Text = "8";
- }
- else
- {
- textBox_display.Text = textBox_display.Text + "8";
- }
- }
- private void button_br9_Click(object sender, EventArgs e)
- {
- if (textBox_display.Text == "0" && textBox_display.Text != null)
- {
- textBox_display.Text = "9";
- }
- else
- {
- textBox_display.Text = textBox_display.Text + "9";
- }
- }
- private void button_br0_Click(object sender, EventArgs e)
- {
- textBox_display.Text = textBox_display.Text + "0";
- }
- private void button_tocka_Click(object sender, EventArgs e)
- {
- textBox_display.Text = textBox_display.Text + ".";
- }
- private void button_off_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- private void button_C_Click(object sender, EventArgs e)
- {
- textBox_display.Text = "0";
- }
- private void button_plus_Click(object sender, EventArgs e)
- {
- PrviBr = Convert.ToDouble(textBox_display.Text);
- textBox_display.Text = "0";
- Operacija = "+";
- }
- private void button_minus_Click(object sender, EventArgs e)
- {
- PrviBr = Convert.ToDouble(textBox_display.Text);
- textBox_display.Text = "0";
- Operacija = "-";
- }
- private void button_umnozak_Click(object sender, EventArgs e)
- {
- PrviBr = Convert.ToDouble(textBox_display.Text);
- textBox_display.Text = "0";
- Operacija = "*";
- }
- private void button_kvocijent_Click(object sender, EventArgs e)
- {
- PrviBr = Convert.ToDouble(textBox_display.Text);
- textBox_display.Text = "0";
- Operacija = "/";
- }
- private void button_jednako_Click(object sender, EventArgs e)
- {
- double DrugiBr;
- double Rez;
- DrugiBr = Convert.ToDouble(textBox_display.Text);
- if (Operacija == "+")
- {
- Rez = (PrviBr + DrugiBr);
- textBox_display.Text = Convert.ToString(Rez);
- PrviBr = Rez;
- }
- if (Operacija == "-")
- {
- Rez = (PrviBr - DrugiBr);
- textBox_display.Text = Convert.ToString(Rez);
- PrviBr = Rez;
- }
- if (Operacija == "*")
- {
- Rez = (PrviBr * DrugiBr);
- textBox_display.Text = Convert.ToString(Rez);
- PrviBr = Rez;
- }
- if (Operacija == "/")
- {
- if (DrugiBr == 0)
- {
- textBox_display.Text = "Nemoguce dijeliti s nulom";
- }
- else
- {
- Rez = (PrviBr / DrugiBr);
- textBox_display.Text = Convert.ToString(Rez);
- PrviBr = Rez;
- }
- }
- }
- private void button_korijen_Click(object sender, EventArgs e)
- {
- PrviBr = Convert.ToDouble(textBox_display.Text);
- double Rez = 0;
- Rez = Math.Sqrt(PrviBr);
- textBox_display.Text = Rez.ToString();
- }
- private void button_log_Click(object sender, EventArgs e)
- {
- PrviBr = Convert.ToDouble(textBox_display.Text);
- double Rez;
- Rez = Math.Log(PrviBr);
- textBox_display.Text = Rez.ToString();
- }
- private void button_sin_Click(object sender, EventArgs e)
- {
- PrviBr = Convert.ToDouble(textBox_display.Text);
- double Rez = 0;
- Rez = Math.Sin(PrviBr);
- textBox_display.Text = Rez.ToString();
- }
- private void button_cos_Click(object sender, EventArgs e)
- {
- PrviBr = Convert.ToDouble(textBox_display.Text);
- double Rez = 0;
- Rez = Math.Cos(PrviBr);
- textBox_display.Text = Rez.ToString();
- }
- private void button_tan_Click(object sender, EventArgs e)
- {
- PrviBr = Convert.ToDouble(textBox_display.Text);
- double Rez = 0;
- Rez = Math.Tan(PrviBr);
- textBox_display.Text = Rez.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement