Guest User

Untitled

a guest
Feb 8th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.38 KB | None | 0 0
  1. using System;
  2. //Maixior:D
  3. namespace ConsoleApplication3
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double temp;
  10.             double temp1;
  11.             int chose;
  12.             string restart;
  13.       Start:
  14.             Console.Clear();
  15.             Console.Write("Witaj w przeliczniku temperatury \n");
  16.             Console.Write("Wybierz jak chcesz przeliczac: \n 1. Zamien °C \n 2. Zamien K \n 3. Zamien °F  \n 4. Chce wyjsc \n");
  17.       Chose:
  18.             chose = Convert.ToInt32(Console.ReadLine());
  19.             switch(chose) {
  20.                 case 1:
  21.                     Console.Write("podaj °C: "); temp = Convert.ToDouble(Console.ReadLine());
  22.                     temp1 = temp + 273.15;
  23.                     Console.Write("tempertra w K: " + temp1  + "\n");
  24.                     temp1 = (temp * 1.8) + 32;
  25.                     Console.Write("tempertra w °F: " + temp1 + "\n");
  26.                     break;
  27.                 case 2:
  28.                     Console.Write("podaj K: "); temp = Convert.ToDouble(Console.ReadLine());
  29.                     temp1 = temp - 273.15;
  30.                     Console.Write("tempertra w °C: " + temp1 + "\n");
  31.                     temp1 = (temp * 1.8) - 459.67;
  32.                     Console.Write("tempertra w °F: " + temp1 + "\n");
  33.                     break;
  34.                 case 3:
  35.                     Console.Write("podaj °F: "); temp = Convert.ToDouble(Console.ReadLine());
  36.                     temp1 = (temp - 32) / 1.8;
  37.                     Console.Write("tempertra w °C: " + temp1 + "\n");
  38.                     temp1 = (temp + 459.67) * 5/9;
  39.                     Console.Write("tempertra w K: " + temp1 + "\n");
  40.                     break;
  41.                 case 4:
  42.                     Environment.Exit(1);
  43.                     break;
  44.                 default:
  45.                     Console.Write("Zly wybor, sproboj jeszcze raz \n");
  46.                     goto Chose;
  47.             }
  48.         End:
  49.             Console.Write("jeszcze raz? y/n \n");
  50.             restart = Console.ReadLine();
  51.             if (restart == "y" || restart == "Y") {
  52.                 goto Start;
  53.             } else if (restart == "n" || restart == "N") {
  54.                 Environment.Exit(1);
  55.             } else {
  56.                 Console.Write("Zly wybor, sproboj jeszcze raz \n");
  57.                 goto End;
  58.             }
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment