Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 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 ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             string userInput;
  15.             bool condition = true;
  16.             while (condition)
  17.             {
  18.                 Console.WriteLine("Välkommen till menyn");
  19.                 Console.WriteLine("Vill du avsluta programmet? Skriv ja/nej");
  20.  
  21.                 // användaren matar in ett svar
  22.                 userInput = Console.ReadLine();
  23.                 if (userInput == "ja")
  24.                 {
  25.                     // Sätt condition till false vilket inte kommer göra avsluta loopen.
  26.                     condition = false;
  27.                     Console.WriteLine("Programmet avslutas...");
  28.                 }
  29.                 else if (userInput == "nej")
  30.                 {
  31.                     Console.WriteLine("Återvänder till menyn");
  32.                 }
  33.                 else
  34.                 {
  35.                     Console.WriteLine("Ogiltig inmatning");
  36.                 }
  37.             }
  38.  
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement