Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // HW
- import java.util.Scanner;
- public class RealPositiveNegative {
- public static void main(String[] args)
- {
- Scanner in = new Scanner (System.in);
- double input, smallestPositive = Double.MAX_VALUE, biggestNegative = -Double.MAX_VALUE;
- System.out.println("Enter 10 real numbers:");
- for(int i = 0; i < 10; i++)
- {
- input = in.nextDouble();
- if(input >= 0 && input < smallestPositive)
- smallestPositive = input;
- else if(input < 0 && input > biggestNegative)
- biggestNegative = input;
- }
- System.out.printf("Smallest positive = %f, biggest negative = %f", smallestPositive, biggestNegative);
- in.close();
- }
- }
Add Comment
Please, Sign In to add comment