Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- first();
- second();
- third();
- }
- public static void first()
- {
- char g;
- int num = 1;
- int sum = 0;
- Console.WriteLine("click A to Add all numbers and hit 0 to stop");
- Console.WriteLine("click F to request a fibonacci numbers");
- Console.WriteLine("click R to request a random number between a given interval");
- switch (g = char.Parse(Console.ReadLine()))
- {
- case 'A':
- while (num != 0)
- {
- Console.WriteLine("please enter a number");
- num = int.Parse(Console.ReadLine());
- if (num == 0)
- Console.WriteLine(sum);
- else
- sum += num;
- }
- break;
- case 'F':
- int a = 0, b = 1, c;
- Console.WriteLine("please enter the numbers of fibonacci");
- int s = num = int.Parse(Console.ReadLine());
- //display the first two elements of fibonacci
- Console.WriteLine(a);
- Console.WriteLine(b);
- for (int i = 0; i < s; i++)
- {
- c = a + b;
- Console.WriteLine(c);
- a = b;
- b = c;
- }
- break;
- case 'R':
- Console.WriteLine("please enter the first interval");
- int x = int.Parse(Console.ReadLine());
- Console.WriteLine("please enter the second interval");
- int y = int.Parse(Console.ReadLine());
- Random rnd = new Random();
- int z = rnd.Next(x, y);
- Console.WriteLine("the random number is " + z);
- break;
- }
- Console.ReadLine();
- }
- public static void second()
- {
- int num = 1, sum = 0, i = 0, max = 0, ave = 0;
- Console.WriteLine("please enter number and hit 0 to stop,");
- while (num != 0)
- {
- Console.WriteLine("enter a number");
- num = int.Parse(Console.ReadLine());
- i++;
- if (num > max) max = num;
- sum += num;
- ave = sum / i+1;
- }
- char g;
- Console.WriteLine("click A to get average");
- Console.WriteLine("click B to get the max value");
- switch (g = char.Parse(Console.ReadLine()))
- {
- case 'A':
- Console.WriteLine(ave);
- break;
- case 'B':
- Console.WriteLine(max);
- break;
- }
- Console.ReadLine();
- }
- public static void third()
- {
- Console.WriteLine("please enter your height");
- double a = double.Parse(Console.ReadLine());
- Console.WriteLine("please enter your weight");
- double b = double.Parse(Console.ReadLine());
- double BMI = b / (a * a);
- Console.WriteLine("your BMI is "+BMI);
- if (BMI <18.5 || BMI> 25)
- {
- Console.WriteLine("its bad");
- }
- else
- {
- Console.WriteLine("its good");
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement