Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 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.             while (true)
  16.             {
  17.                 Console.WriteLine("Välkommen till menyn");
  18.                 Console.WriteLine("Vill du avsluta programmet? Skriv ja/nej");
  19.  
  20.                 // användaren matar in ett svar
  21.                 userInput = Console.ReadLine();
  22.                 if (userInput == "ja")
  23.                 {
  24.                     // Avsluta loopen med hjälp av break
  25.                     Console.WriteLine("Programmet avslutas...");
  26.                     break;
  27.                 }
  28.                 else if (userInput == "nej")
  29.                 {
  30.                     Console.WriteLine("Återvänder till menyn");
  31.                 }
  32.                 else
  33.                 {
  34.                     Console.WriteLine("Ogiltig inmatning");
  35.                 }
  36.             }
  37.  
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement