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;
- namespace targil51p131
- {
- class Program
- {
- //Input - get 10 numbers
- //Output - the heighest negtive number and the lowest positive number
- static void Main(string[] args)
- {
- double num, min, max;
- Console.WriteLine("Please Enter A Number");
- num = double.Parse(Console.ReadLine());
- if (num >= 0)
- {
- min = num;
- max = 0;
- }else
- {
- max = num;
- min = -1;
- }
- for (int i = 1; i <= 9; i++)
- {
- if (num >= 0 && min == -1)
- {
- min = num;
- min = Math.Min(min, num);
- Console.WriteLine("Please Enter A Number");
- }else
- if (num >= 0 && min != -1)
- {
- min = Math.Min(min, num);
- Console.WriteLine("Please Enter A Number");
- }else
- if (num < 0 && max == 0)
- {
- max = num;
- max = Math.Max(max, num);
- Console.WriteLine("Please Enter A Number");
- }else
- if (num < 0 && max != 0)
- {
- max = Math.Max(max, num);
- Console.WriteLine("Please Enter A Number");
- }
- num = double.Parse(Console.ReadLine());
- }
- Console.WriteLine("The min positive number is "+min);
- Console.WriteLine("The max negtive number is "+max);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement