MuffinMonster

Class Task 18#

Oct 23rd, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 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.             int students = 3, physics = 0, computers = 0, pc = 0;
  14.             double avg, compavg = 0, physavg = 0, pcavg = 0;
  15.             int input;
  16.             for (; students > 0; students--)
  17.             {
  18.                 Console.WriteLine("Do you study 'computers' or 'physics'? | 1 for physics, 0 for conputers");
  19.                 input = int.Parse(Console.ReadLine());
  20.                 Console.WriteLine("Enter your avg: ");
  21.                 avg = double.Parse(Console.ReadLine());
  22.                 if (input == 0)
  23.                 {
  24.                     computers++;
  25.                     compavg = compavg + avg;
  26.                 }
  27.                 else
  28.                 {
  29.                     physics++;
  30.                     physavg = physavg + avg;
  31.                 }
  32.                 if (input == 0 && avg > 80)
  33.                 {
  34.                     pc++;
  35.                     pcavg = pcavg + avg;
  36.                 }
  37.             }
  38.             Console.WriteLine("The ammount of students in computer sience class with avg over 80 is " + pc);
  39.             Console.WriteLine("Their avg is: " + (pcavg / pc));
  40.             Console.WriteLine("Physics class student's avg is: " + (physavg / physics));
  41.             Console.WriteLine("Computer sience all student's avg is: " + (compavg / computers));
  42.             if ((compavg / computers) > (physavg / physics))
  43.             {
  44.                 Console.WriteLine("Perfect!");
  45.             }
  46.             else
  47.                 Console.WriteLine("Fix your grade!");
  48.             Console.ReadKey();
  49.         }
  50.     }
  51. }
Add Comment
Please, Sign In to add comment