Advertisement
GraionDilach

Osztályzatok switch-casel.

Oct 24th, 2011
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication9
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int oszt;
  13.             do
  14.             {
  15.                 //ellenőrzőtt bevitel
  16.                 do
  17.                 {
  18.                     Console.WriteLine("Kérem az osztályzatot:");
  19.                     oszt = int.Parse(Console.ReadLine());
  20.                     if (oszt > 6 || oszt < -1)
  21.                     {
  22.                         Console.WriteLine("Rossz osztályzat, add meg újra!");
  23.                     }
  24.                 } while (oszt > 6 && oszt < -1);
  25.  
  26.                 //switchcase
  27.                 switch (oszt){case 1:
  28.                         Console.WriteLine("\nOsztályzat: elégtelen\n");
  29.                         break;
  30.  
  31.                       case 2:
  32.                      Console.WriteLine("\nOsztályzat: elégséges\n");
  33.                      break;
  34.  
  35.                     case 3:
  36.                     Console.WriteLine("\nOsztályzat: közepes\n");
  37.                     break;
  38.  
  39.                     case 4:
  40.                     Console.WriteLine("\nOsztályzat: jó\n");
  41.                     break;
  42.  
  43.                 case 5:
  44.                     Console.WriteLine("\nOsztályzat: jeles\n");
  45.                     break;
  46.  
  47.                     //semmit nem írunk ki, mert hát nincs mit
  48.                     default:
  49.                     break;
  50.                    }
  51.  
  52.             } while (oszt!=0);
  53.  
  54.  
  55.         }
  56.     }
  57. }
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement