Advertisement
AvengersAssemble

MathFunctionsHW-YuvalA(FromUser)

Oct 3rd, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication25
  4. {
  5.     class App
  6.     {
  7.         static void Main()
  8.         {
  9.             MathExerciseNine();
  10.             MathExerciseTwelve();
  11.             MathExerciseThirteen();
  12.             MathExerciseFiftheen();
  13.         }
  14.         static void MathExerciseNine()
  15.         {
  16.             double n1, n2, n3, avg;
  17.             Random rnd = new Random();
  18.             n1 = (double) rnd.Next(101, 1000) / 1000;
  19.             n2 = (double)rnd.Next(101, 1000) / 1000;
  20.             n3 = (double)rnd.Next(101, 1000) / 1000;
  21.             avg = (n1 + n2 + n3) / 3;
  22.             Console.WriteLine(avg);
  23.         }
  24.         static void MathExerciseTwelve()
  25.         {
  26.             float a, b, c, size, p;
  27.             a = float.Parse(Console.ReadLine());
  28.             b = float.Parse(Console.ReadLine());
  29.             c = float.Parse(Console.ReadLine());
  30.             p = (a + b + c) / 2;
  31.             size = (float) Math.Sqrt(p*(p-a)*(p-b)*(p-c));
  32.             Console.WriteLine("Triangle size: {0}", size);
  33.         }
  34.         static void MathExerciseThirteen()
  35.         {
  36.             decimal num = decimal.Parse(Console.ReadLine());
  37.             int agorot = (int)(num * 100) % 100;
  38.             Console.WriteLine("{0} shekels and {1} agorot.", (int)num, agorot);
  39.         }
  40.         static void MathExerciseFiftheen()
  41.         {
  42.             double num = double.Parse(Console.ReadLine());
  43.             double keptForLater = ((num * 10) % 10) / 10;
  44.             if (keptForLater >= 0.5)
  45.                 keptForLater += -1;
  46.             num = Math.Round(num);
  47.             Console.WriteLine("Rounded mark: {0}, kept for final mark: {1}", num, keptForLater);
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement