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
100%(2)2 out of 2 people found this document helpful
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.");