Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace calc
- {
- class Program
- {
- static void Main(string[] args)
- {
- // Määritellään muuttujat
- int numOne = 0;
- int numTwo = 0;
- int result = 0;
- string operation = "+";
- // Käyttäjä syöttää luvut ja toiminnon
- Console.WriteLine("Anna kokonaisluku");
- try
- {
- numOne = int.Parse(Console.ReadLine());
- }
- catch
- {
- Console.WriteLine("Numbers only, son! Re-enter the number.");
- numOne = int.Parse(Console.ReadLine());
- }
- Console.WriteLine("Anna laskutoimitus + tai - tai * tai /");
- operation = Console.ReadLine();
- Console.WriteLine("Anna toinen kokonaisluku");
- try
- {
- numTwo = int.Parse(Console.ReadLine());
- }
- catch
- {
- Console.WriteLine("Numbers only, son! Re-enter the number.");
- numTwo = int.Parse(Console.ReadLine());
- }
- // Suoritetaan lasku käyttäjän antamilla toiminnoilla
- if (operation == "*")
- {
- result = numOne * numTwo;
- }
- if (operation == "+")
- {
- result = numOne + numTwo;
- }
- if (operation == "/")
- {
- if (numTwo == 0)
- {
- result = 0;
- }
- else
- {
- result = numOne / numTwo;
- }
- }
- if (operation == "-")
- {
- result = numOne - numTwo;
- }
- // Output
- Console.WriteLine("Tulos on " + result);
- // KEEP THE SYSTME RUNNINK PLS
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement