Store checkout management of Java Foundation Program

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.