MuffinMonster

Class Task 17#

Oct 23rd, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 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 families, boys, totalboys = 0, girls, totalgirls = 0, equaltot = 0, kids = 0;
  14.             int tempfamily, avg;
  15.             Console.Write("Enter the ammount of families you are about to check: ");
  16.             families = int.Parse(Console.ReadLine());
  17.             tempfamily = families;
  18.             for (; families > 0; families--)
  19.             {
  20.                 Console.Write("Ammount of boys in the family: ");
  21.                 boys = int.Parse(Console.ReadLine());
  22.                 totalboys = totalboys + boys;
  23.                 Console.Write("Ammount of girls in the family: ");
  24.                 girls = int.Parse(Console.ReadLine());
  25.                 totalgirls = totalgirls + girls;
  26.                 kids = boys + girls;
  27.                 Console.WriteLine("There are " + kids + " kids in the family! Yay!");
  28.                 if (boys == girls)
  29.                 {
  30.                     equaltot++;
  31.                 }
  32.             }
  33.             avg = totalgirls / tempfamily; // Can't be avg of double for people! (for ex: avg of 3.444 girls)
  34.             Console.WriteLine("There is an avg of " + avg + " girls in each family");
  35.             Console.WriteLine("There are " + equaltot + " families with ammount of boys equal to girls");
  36.             Console.ReadKey();
  37.         }
  38.     }
  39. }
Add Comment
Please, Sign In to add comment