Advertisement
Guest User

Untitled

a guest
May 17th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Övningar_2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // #1
  14.             /*
  15.              * Variabler lagrar  information
  16.              * SOm tex variablen int som lagrar heltal
  17.              * */
  18.  
  19.             string namn;
  20.  
  21.             Console.WriteLine("Skriv ditt namn: ");
  22.             namn = Console.ReadLine();
  23.  
  24.             string efternamn;
  25.             Console.WriteLine("Skriv ditt efternamn");
  26.             efternamn = Console.ReadLine();
  27.  
  28.             Console.WriteLine("Hej " + namn + " " + efternamn);
  29.             Console.ReadKey();
  30.  
  31.             int tal1, tal2;
  32.  
  33.             Console.WriteLine("Skriv in tal 1");
  34.  
  35.             tal1 = Convert.ToInt16(Console.ReadLine());
  36.  
  37.             Console.WriteLine("Skriv in tal 2");
  38.  
  39.             tal2 = Convert.ToInt16(Console.ReadLine());
  40.  
  41.             Console.WriteLine("Summa = " + (tal1 + tal2));
  42.             Console.WriteLine("Produkten " + (tal1 * tal2));
  43.             Console.WriteLine("Divisionen = " + (tal1 / tal2));
  44.  
  45.             Console.ReadLine();
  46.  
  47.             // #2
  48.             Console.WriteLine("Skriv in ditt mönsterdjup");
  49.             double däckDjup = Convert.ToDouble(Console.ReadLine());
  50.             if (däckDjup < 1.3)
  51.             {
  52.                 Console.WriteLine("Olaglit däck mönster");
  53.             }
  54.             else
  55.                 Console.WriteLine("Godkänt däck");
  56.  
  57.             Console.ReadLine();
  58.  
  59.             // #Färgbrickor
  60.             Console.WriteLine("Skriv in besökarens ålder");
  61.             double age = Convert.ToDouble(Console.ReadLine());
  62.             if (age <= 12)
  63.             {
  64.                 Console.WriteLine("Brickan ska vara vit");
  65.             }
  66.             else if (age <= 18)
  67.             {
  68.                 Console.WriteLine("Brickan ska vara grön");
  69.             }
  70.             else if (age <= 25)
  71.             {
  72.                 Console.WriteLine("Brickan ska vara röd");
  73.             }
  74.             else if (age <= 99)
  75.             {
  76.                 Console.WriteLine("Brickan ska vara blå");
  77.             }
  78.             else
  79.             {
  80.                 Console.WriteLine("Ogiltig ålder");
  81.             }
  82.             Console.ReadLine();
  83.  
  84.             //#3
  85.             Console.WriteLine("Mata in tal 1");
  86.             tal1 = Convert.ToInt16(Console.ReadLine());
  87.             Console.WriteLine("Skriv in tal 2");
  88.             tal2 = Convert.ToInt16(Console.ReadLine());
  89.             if (tal1 > tal2)
  90.             {
  91.                 Console.WriteLine("Tal 1 är större än tal 2");
  92.             }
  93.             else if (tal1 < tal2)
  94.             {
  95.                 Console.WriteLine("Tal 2 är större an tal 1");
  96.             }
  97.             else if (tal1 == tal2)
  98.             {
  99.                 Console.WriteLine("Tal 1 och tal 2 är lika stora");
  100.             }
  101.             Console.ReadLine();
  102.  
  103.             //#4
  104.             Console.WriteLine("Mata in tal 1");
  105.             int numInt = int.Parse(Console.ReadLine());
  106.             bool checkNum7 = (numInt % 7) == 0;
  107.          
  108.            
  109.             // Övningsuppgift 4
  110.             int tal = int.Parse(Console.ReadLine());
  111.  
  112.             switch (tal)
  113.             {
  114.                 case 1:
  115.                     Console.WriteLine("Ett");
  116.                     break;
  117.                 case 2:
  118.                     Console.WriteLine("Två");
  119.                     break;
  120.                 case 3:
  121.                     Console.WriteLine("Tre");
  122.                     break;
  123.                 case 4:
  124.                     Console.WriteLine("Fyra");
  125.                     break;
  126.                 default:
  127.                     Console.WriteLine("Ogiltigt Alternativ");
  128.                     break;
  129.  
  130.                     //4.2
  131.                     Console.WriteLine("Press key to move ");
  132.                     int move;
  133.                     switch(move)
  134.                     {
  135.                         case 'w':
  136.                             {
  137.                                 Console.WriteLine("You strolles west");
  138.                                 break;
  139.                             }
  140.                         case 'n':
  141.                             {
  142.                                 Console.WriteLine("You walk north");
  143.                                 break;
  144.                             }  
  145.                         case 's':
  146.                             {
  147.                                 Console.WriteLine("You travel south");
  148.                                 break;
  149.                             }
  150.                         case 'e':
  151.                             {
  152.                                 Console.WriteLine("You wander east");
  153.                                 break;
  154.                             }
  155.                     }
  156.                      
  157.  
  158.                        
  159.                    
  160.                     }
  161.  
  162.         }
  163.         }
  164.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement