Advertisement
razexude

Løsning

May 10th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1.         static void Main(string[] args)
  2.         {
  3.             int antallB = 0;
  4.             int maksAntall = 30;
  5.             int stasjoner = 4;
  6.  
  7.             Console.Title = "Buss";
  8.  
  9.             for (int stasjon = 1; stasjon <= stasjoner; stasjon++){
  10.                 Console.WriteLine("På stasjon: " + stasjon + " stiger det på: ");
  11.  
  12.                 try{
  13.                     antallB += Convert.ToInt32(Console.ReadLine());
  14.                 }
  15.                 catch (Exception e){
  16.                     Console.WriteLine("En feil har oppstått: " + e.Message);
  17.                 }
  18.  
  19.                 if (antallB > maksAntall){
  20.                     antallB = maksAntall;
  21.                 }
  22.                 Console.WriteLine("Antall passasjerer på bussen: " + antallB);
  23.             }
  24.             Console.WriteLine("Siste holdeplass er nå nådd. Antall passasjerer på bussen: " + antallB);
  25.             Console.ReadKey();
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement