Guest User

Untitled

a guest
Apr 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ASS_1_practise
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. { char [,] studentArray = new char { {'A','B','A','C','C','D','E','E','A','D'},
  12. {'D','B','A','B','C','A','E','E','A','D'},
  13. {'E','D','D','A','C','B','E','E','A','D'},
  14. {'C','B','A','E','D','C','E','E','A','D'},
  15. {'A','B','D','C','C','D','E','E','A','D'},
  16. {'B','B','E','C','C','D','E','E','A','D'},
  17. {'B','B','A','C','C','D','E','E','A','D'},
  18. {'E','B','E','C','C','D','E','E','A','D'}};
  19. string [ ] namesArray = new string { "Jack ", "John ", "Jill ", "Mary ", "Peter", "Bob ", "Nancy", "Pat " };
  20. char [ ] keyArray = new char {'D','B','D','C','C','D','A','E','A','D'};
  21. int [ ] scoreArray = new int { 2, 2, 5, 3, 3, 4, 4, 4, 6, 7 };
  22. int [ ] totalScoreArray = new int[8];
  23. for(int i = 0; i < 8; i++){
  24. for (int j = 0; j < 10; j++) { if (studentArray[i, j] = keyArray[j]) totalScoreArray[i] += scoreArray[j]; }
  25. }
  26. int totalFullScore=0;
  27. for (int k = 0; k < 10; k++) totalFullScore += scoreArray[k];
  28. char grade; double [ ] percentArray = new double[8];
  29. for (int w = 0; w < 8; w++) percentArray[w] = totalScoreArray[w] / totalFullScore;
  30. char [ ] gradeArray = new char [8];
  31. for (int v = 0; v < 8; v++)
  32. { if (percentArray[v] >= 0.9) gradeArray[v] = 'A';
  33. else if (percentAray[v] >= 0.8) gradeArray[v] = 'B';
  34. else if (percentAray[v] >= 0.7) gradeArray[v] = 'C';
  35. else if (percentAray[v] >= 0.6) gradeArray[v] = 'D';
  36. else if (percentAray[v] < 0.6) gradeArray[v] = 'F';
  37. }
  38. int sumtotalFullScore = 0;
  39. for(int z=0;z<8;z++)sumtotalFullScore+=totalScoreArray[z];
  40. double average = sumtotalFullScore/8;
  41. int squareSum=0;
  42. for(int i=0;i<8;i++)squareSum+=totalScoreArray[i]*totalScoreArray[i];
  43. double variance=squareSum/8-average*average;
  44. double StdVariance = Math.Round(variance, 2);
  45. Console.WriteLine("Student " + "Score " + "Grade ");
  46. for (int i = 0; i < 8; i++)
  47. {
  48. Console.WriteLine(namesArray[i] + " " + totalScoreArray[i] + " " + gradeArray[i]);}
  49.  
  50. Console.WriteLine("Average: " + average);
  51. Console.WriteLine("Std.Dev: " + StdVariance);
  52.  
  53. int countA = 0; int countB = 0; int countC = 0; int countD = 0; int countF = 0;
  54. for (int i = 0; i < 8; i++)
  55. {
  56. if (grade[i] == 'A') countA++;
  57. else if (grade[i] == 'B') countB++;
  58. else if (grade[i] == 'C') countC++;
  59. else if (grade[i] == 'D') countD++;
  60. else countF++;
  61. }
  62. Console.Write('A' + "|"); for (int i = 0; i < countA; i++) Console.Write("*");
  63. Console.WriteLine();
  64. Console.Write('B' + "|"); for (int i = 0; i < countB; i++) Console.Write("*");
  65. Console.WriteLine();
  66. Console.Write('C' + "|"); for (int i = 0; i < countC; i++) Console.Write("*");
  67. Console.WriteLine();
  68. Console.Write('D' + "|"); for (int i = 0; i < countD; i++) Console.Write("*");
  69. Console.WriteLine();
  70. Console.Write('F' + "|"); for (int i = 0; i < countF; i++) Console.Write("*");
  71.  
  72. Console.WriteLine("Student " + "Score " + "Grade");
  73. for (int i = 0; i < 8; i++) { if (gradeArray[i] == 'A')Console.WriteLine(namesArray[i] + " " + totalScoreArray[i] + " " + "A"); }
  74. for (int i = 0; i < 8; i++) { if (gradeArray[i] == 'B')Console.WriteLine(namesArray[i] + " " + totalScoreArray[i] + " " + "B"); }
  75. for (int i = 0; i < 8; i++) { if (gradeArray[i] == 'C')Console.WriteLine(namesArray[i] + " " + totalScoreArray[i] + " " + "C"); }
  76. for (int i = 0; i < 8; i++) { if (gradeArray[i] == 'D')Console.WriteLine(namesArray[i] + " " + totalScoreArray[i] + " " + "D"); }
  77. for (int i = 0; i < 8; i++) { if (gradeArray[i] == 'F')Console.WriteLine(namesArray[i] + " " + totalScoreArray[i] + " " + "F"); }
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98. }
  99. }
  100. }
Add Comment
Please, Sign In to add comment