Guest User

Untitled

a guest
Jan 10th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 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 ConsoleApplication10
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Enter the amount of students in the class.");
  14. int amount = int.Parse(Console.ReadLine());
  15. string[] studentname = new string[amount];
  16. double[] grades = new double[amount];
  17. double highestGrade=0;
  18. double avergaeGrade;
  19. double totalgrades = 0;
  20. string highestgradestudent= "";
  21.  
  22. for(int i=0; i<amount;i++)
  23. {
  24. Console.WriteLine("Enter the name of student{0} .", i+1);
  25. studentname[i] = Console.ReadLine();
  26. Console.WriteLine("Enter the grades of student{0} .", i + 1);
  27. grades[i] = double.Parse(Console.ReadLine());
  28. totalgrades = totalgrades + grades[i];
  29. if (grades[i] > highestGrade)
  30. {
  31. highestGrade = grades[i];
  32. highestgradestudent = studentname[i];
  33. }
  34. }
  35.  
  36. avergaeGrade = totalgrades / amount;
  37. Console.WriteLine("Average of student's grades are: " + avergaeGrade);
  38. //highestGrade = grades.Max();
  39. Console.WriteLine("Highest grades are: " + highestGrade + " of " + highestgradestudent);
  40.  
  41. Console.ReadLine();
  42. }
  43. }
  44. }
Add Comment
Please, Sign In to add comment