Project Flow : The selected commodity price and commodity quantity, each statistic, calculates the total price, then the total price accumulates, and finally chooses to exit or empty all the memory space. Make the next checkout ;
Package Com.zhiyou100;import Java.util.scanner;import Java.util.function.predicate;public class MyShop {public static void Main (string[] args) {Boolean sc =true;while (SC) {double total=0; Scanner Scanner =new Scanner (system.in); System.out.println ("Welcome to my store!") "); while (true) { System.out.print ("Please enter Unit Price:");d ouble price=scanner.nextdouble (); System.out.print ("Please Enter quantity:"); int number=scanner.nextint (); total+=price*number; System.out.printf ("Cumulative result: ¥:%.2f%n", total); System.out.println ("Qing 0 please press C, exit please press Q, continue to press any key"); Scanner.nextline (); String flog=scanner.nextline (); if (Flog.equals ("C")) {total=0;} else if (flog.equals ("Q")) {sc=false;break;} else {continue;//continue continue}}}} }
Store checkout management of Java Foundation Program