Advertisement
Kirsiina

Kayttajansyote

Sep 5th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Kayttajan_syote
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             Console.WriteLine("Anna ensimmäinen luku");
  11.             string kayttajansyote = Console.ReadLine();
  12.             Console.WriteLine("Anna toinen luku");
  13.             string kayttajansyote2 = Console.ReadLine();
  14.             Console.WriteLine("Kerro haluatko summata luvut tai laskea lukujen erotuksen.");
  15.             Console.WriteLine("Kirjoita plus tai miinus");
  16.             string syote = Console.ReadLine();
  17.             double summa = double.Parse(kayttajansyote) + double.Parse(kayttajansyote2);
  18.             double erotus = double.Parse(kayttajansyote) - double.Parse(kayttajansyote2);
  19.  
  20.             if (syote == "plus")
  21.             {
  22.                 if (summa >= 10)
  23.                 {
  24.                     Console.ForegroundColor = ConsoleColor.Red;
  25.                     Console.WriteLine("Lukujesi summa on " + summa);
  26.                 } else
  27.                 {
  28.                     Console.ForegroundColor = ConsoleColor.Green;
  29.                     Console.WriteLine("Lukujesi summa on " + summa);
  30.                 }
  31.             }
  32.  
  33.             if (syote == "miinus")
  34.             {
  35.                 if (erotus >= 10)
  36.                 {
  37.                     Console.ForegroundColor = ConsoleColor.Red;
  38.                     Console.WriteLine("Lukujen erotus on " + erotus);
  39.                 } else
  40.                 {
  41.                     Console.ForegroundColor = ConsoleColor.Green;
  42.                     Console.WriteLine("Lukujesi erotus on " + erotus);
  43.                 }
  44.             }
  45.  
  46.             Console.ReadLine();
  47.  
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement