Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- final int LENGTH = 100;
- double[] values = new double[LENGTH];
- int currentSize = 0;
- System.out.println("Please enter values, Q to quit:");
- Scanner in = new Scanner(System.in);
- while (in.hasNextDouble() && currentSize < values.length)
- {
- values[currentSize] = in.nextDouble();
- currentSize++;
- }
- double smallest = values[0];
- for (int i = 0; i < currentSize; i++)
- {
- if (values[i] < smallest)
- {
- smallest = values[i];
- }
- }
- System.out.println("Smallest: " + smallest);
- double total = 0;
- for (int i = 0; i < values.length; i++)
- {
- total = total + values[i];
- }
- double max = total - smallest;
- System.out.println(max);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement