elena1234

BonusScoringSystem

Oct 9th, 2020 (edited)
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. namespace BonusScoringSystem
  3. {
  4.     class MainClass
  5.     {
  6.         public static void Main(string[] args)
  7.         {
  8.             int studentsCount = int.Parse(Console.ReadLine());
  9.             int lecturesCount = int.Parse(Console.ReadLine());
  10.             int additinalBonus = int.Parse(Console.ReadLine());
  11.             double totalBonus = 0;
  12.             double maxTotalBonus = 0;
  13.             int maxStudentAttendances = 0;
  14.  
  15.             for (int i = 0; i < studentsCount; i++)
  16.             {
  17.                 int studentAttendances = int.Parse(Console.ReadLine());
  18.                 totalBonus =(double) studentAttendances / lecturesCount * (5 + additinalBonus);
  19.  
  20.                 if (totalBonus > maxTotalBonus)
  21.                 {
  22.                     maxTotalBonus = totalBonus;
  23.                     maxStudentAttendances = studentAttendances;
  24.                 }
  25.             }
  26.  
  27.             Console.WriteLine($"Max Bonus: {(int)Math.Round((double)maxTotalBonus,MidpointRounding.AwayFromZero)}.");
  28.             Console.WriteLine($"The student has attended {maxStudentAttendances} lectures.");
  29.         }
  30.     }
  31. }
  32.  
  33.  
Add Comment
Please, Sign In to add comment