Trunc.java - import java.util.Scanner\/TwoDps.java\/Displays running total of numbers in lines of standard\/input correct to two decimal places\/Uses an out

Trunc.java - import...

This preview shows page 1 - 2 out of 2 pages.

import java.util.Scanner;//TwoDps.java//Displays running total of numbers in lines of standard//input correct to two decimal places.//Uses an out of range number(<-100 or >100) to quit.public class Trunc { // TwoDPs.javapublic static void main(String[] args) {Scanner input = new Scanner(System.in);double total = 0;boolean flag = true;System.out.println("Use an out of range entry <-100 or >100 to quit.");while(flag) {System.out.println("Enter a number on a line:");double d = input.nextDouble();if (outOfRange(d)) {flag = false;}else {dispTwoDPs("The number value is: ",d);total = total + d;dispTwoDPs("The total is: ",total);System.out.println();System.out.println("Next.");
Background image
Background image

You've reached the end of your free preview.

Want to read both pages?

  • One '14
  • Decimal, Rational number

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture