Advertisement
Hazem3529

model 2012 Q5

Jun 4th, 2015
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.87 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 _2D_array_class
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("enter the numbers of students");
  14.             int students = int.Parse(Console.ReadLine());
  15.             Console.WriteLine("enter the number of subjects");
  16.             int subjects = int.Parse(Console.ReadLine());
  17.  
  18.             int[,] arr = new int[students, subjects];
  19.  
  20.             for (int i = 0; i < arr.GetLength(0); i++)
  21.             {
  22.                 for (int j = 0; j <arr.GetLength(1); j++)
  23.                 {
  24.  
  25.                     Console.WriteLine("enter subject {0} for student {1}",j+1,i+1);
  26.                     arr[i, j] = int.Parse(Console.ReadLine());
  27.  
  28.                 }
  29.             }
  30.             /// 1 print the grade and the avarage for each subject
  31.             /// colum sabt el row bytgyr
  32.             Console.ForegroundColor = ConsoleColor.Green;
  33.             for (int i = 0; i < subjects; i++)
  34.             {
  35.                 int total = 0;
  36.                 double avarge = 0.0;
  37.  
  38.                 Console.WriteLine("for subject {0}",(i+1));
  39.                 for (int j = 0; j < students; j++)
  40.                 {
  41.                     Console.Write(arr[i,j]+"  ");
  42.                     total += arr[i, j];
  43.                 }
  44.                 Console.WriteLine("the avarage is {0}",(total/(double)students));
  45.             }
  46.            //print the max and min
  47.             int max = arr[0,0];
  48.             int min = arr[0, 0];
  49.             for (int i = 0; i < students; i++)
  50.             {
  51.                 for (int j = 0; j < subjects; j++)
  52.                 {
  53.                     if (arr[i, j] > max) max = arr[i, j];
  54.                     if (arr[i, j]< min) min = arr[i, j];
  55.                    
  56.                 }
  57.             }
  58.             Console.ForegroundColor = ConsoleColor.Red;
  59.             Console.WriteLine("\n the max is {0} and the min is {1} \n \n ",max,min);
  60.             Console.WriteLine("______________________");
  61.             Console.ForegroundColor = ConsoleColor.Yellow;
  62.         //over all zft حسبى الله و نعم الوكيل
  63.  
  64.         for (int k = 0; k < 100; k+=10)
  65.             {
  66.                 int count = 0;
  67.                 for (int i = 0; i < students; i++)
  68.                 {
  69.                     for (int j = 0; j < subjects; j++)
  70.                     {
  71.                         if (arr[i,j]<=k+9&&arr[i,j]>=k)
  72.                         {
  73.                             count++;
  74.                         }
  75.  
  76.                     }
  77.                 }
  78.                 Console.Write("{0}-{1} : ",k,(k+9));
  79.                 for (int i = 0; i < count; i++)
  80.                 {
  81.                     Console.Write("*");
  82.                 }
  83.  
  84.                 Console.WriteLine();
  85.             }
  86.  
  87.  
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement