Advertisement
AvengersAssemble

Untitled

Sep 6th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 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 Functions
  8. {
  9.     class Program
  10.     {
  11.         static double check(double goodDiameter, int amount)
  12.         {
  13.             int good=0;
  14.                for (int i = 0; i < amount; i++)
  15.             {
  16.                 Console.WriteLine("Enter made diameter");
  17.                 double actualDiameter = double.Parse(Console.ReadLine());
  18.                 if (goodDiameter >= actualDiameter)
  19.                    if ((goodDiameter - actualDiameter) <= 1)
  20.                       good++;
  21.                 if(actualDiameter>=goodDiameter)
  22.                    if((actualDiameter-goodDiameter) <= 1)
  23.                      good++;
  24.             }
  25.             return good;
  26.         }
  27.         static void Main(string[] args)
  28.         {
  29.             for (int a = 0; a < 50; a++)
  30.             {
  31.                 Console.WriteLine("Enter standard diameter:");
  32.                 double goodDiameter = double.Parse(Console.ReadLine());
  33.                 Console.WriteLine("Enter amount made:");
  34.                 int amount = int.Parse(Console.ReadLine());
  35.                 check(goodDiameter, amount);
  36.                 Console.WriteLine(check(goodDiameter, amount));
  37.  
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement