Advertisement
Hazem3529

students grades

Jun 5th, 2015
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 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 ConsoleApplication8
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("enter the number of students");
  14.             int students = int.Parse(Console.ReadLine());
  15.             Console.WriteLine("enter the number of Questions");
  16.             int questions = int.Parse(Console.ReadLine());
  17.  
  18.             char[,] MCQ = new char[students, questions];
  19.             char[] key = new char[questions];
  20.             Console.WriteLine("enter the answer key");
  21.             //input of the answer key
  22.             for (int i = 0; i < key.Length; i++)
  23.             {
  24.                 key[i] = char.Parse(Console.ReadLine());
  25.             }
  26.  
  27.             //input of students answers
  28.             for (int i = 0; i < students; i++)
  29.             {
  30.                 Console.WriteLine("enter the answers of studnet {0}",i+1);
  31.                 for (int j = 0; j < questions; j++)
  32.                 {
  33.  
  34.                     MCQ[i, j] = char.Parse(Console.ReadLine());
  35.                 }
  36.        
  37.             }
  38.             //ts7e7 el MCQ
  39.  
  40.             for (int i = 0; i < students; i++)
  41.             {
  42.                 int counter = 0;
  43.                 for (int j = 0; j < questions; j++)
  44.                 {
  45.                     if (MCQ[i,j]==key[j])
  46.                     {
  47.                         counter++;
  48.                     }
  49.  
  50.                  
  51.                
  52.                 }
  53.                 Console.WriteLine("the number of correct answers for student {0} is {1}", (i + 1), counter);
  54.             }
  55.    
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement