MuffinMonster

Class Task 16#

Oct 23rd, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 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 ConsoleApplication9
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //numbers:
  14.             int num1, num2, num3;
  15.             //each group:
  16.             double avg = 0, group;
  17.             //total:
  18.             double totalnums = 0, sum = 0;
  19.             //equal:
  20.             double equaltot = 0, equalsum = 0;
  21.  
  22.  
  23.             for (int i = 0; i < 100; i++)
  24.             {
  25.                 num1 = int.Parse(Console.ReadLine());
  26.                 num2 = int.Parse(Console.ReadLine());
  27.                 num3 = int.Parse(Console.ReadLine());
  28.                 group = num1 + num2 + num3;
  29.                 avg = group / 3;
  30.                 if (num1 == avg)
  31.                 {
  32.                     Console.WriteLine("The first number is equal to the avg!");
  33.                 }
  34.                 else
  35.                 {
  36.                     Console.WriteLine("The first number is not equal to the avg!");
  37.                 }
  38.                 Console.WriteLine("avg: " + avg);
  39.                 totalnums = totalnums + 3;
  40.                 sum = sum + group;
  41.                 if (num1 == num2 && num1 == num3)
  42.                 {
  43.                     equaltot = equaltot + 3;
  44.                     equalsum = equalsum + group;
  45.                 }
  46.             }
  47.             avg = sum / totalnums;
  48.             Console.WriteLine("The avg of all numbers together is: " + avg);
  49.             avg = equalsum / equaltot;
  50.             Console.WriteLine("The avg of all gorups with all 3 numbers same is: " + avg);
  51.         }
  52.     }
  53. }
Add Comment
Please, Sign In to add comment