Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication25
- {
- class App
- {
- static void Main()
- {
- MathExerciseNine();
- MathExerciseTwelve();
- MathExerciseThirteen();
- MathExerciseFiftheen();
- }
- static void MathExerciseNine()
- {
- double n1, n2, n3, avg;
- Random rnd = new Random();
- n1 = (double) rnd.Next(101, 1000) / 1000;
- n2 = (double)rnd.Next(101, 1000) / 1000;
- n3 = (double)rnd.Next(101, 1000) / 1000;
- avg = (n1 + n2 + n3) / 3;
- Console.WriteLine(avg);
- }
- static void MathExerciseTwelve()
- {
- float a, b, c, size, p;
- a = float.Parse(Console.ReadLine());
- b = float.Parse(Console.ReadLine());
- c = float.Parse(Console.ReadLine());
- p = (a + b + c) / 2;
- size = (float) Math.Sqrt(p*(p-a)*(p-b)*(p-c));
- Console.WriteLine("Triangle size: {0}", size);
- }
- static void MathExerciseThirteen()
- {
- decimal num = decimal.Parse(Console.ReadLine());
- int agorot = (int)(num * 100) % 100;
- Console.WriteLine("{0} shekels and {1} agorot.", (int)num, agorot);
- }
- static void MathExerciseFiftheen()
- {
- double num = double.Parse(Console.ReadLine());
- double keptForLater = ((num * 10) % 10) / 10;
- if (keptForLater >= 0.5)
- keptForLater += -1;
- num = Math.Round(num);
- Console.WriteLine("Rounded mark: {0}, kept for final mark: {1}", num, keptForLater);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement