Java version-----Store shopping System

Source: Internet
Author: User

Buy.java

 Public class Buy {    publicstaticvoid  main (string[] args) {        //  TODO auto-generated Method Stub        new  shops ();          }}

Shops.java

ImportJava.util.Scanner; Public classShops { Public Static intm;  Public Static  intNumbercup = 0, Numberrubber = 0, Numberpen = 0, Allprice = 0; /**constructor Function*/     Publicshops () {showallgoods (); }        /**Show All Products*/     Public voidShowallgoods () {System.out.println ("Welcome to the self-service supermarket, we have the following products \n1. Pen \n2. Water Cup \n3. Rubber \n4. exit \ n Please enter the appropriate number to purchase:"); Scanner Scanner=NewScanner (system.in); inti =Scanner.nextint (); Switch(i) { Case1: System.out.println ("Please Enter quantity:");           Inputcode (); Numberpen+=m;                       Showallbuygoods ();  Break;  Case2: System.out.println ("Please Enter quantity:");            Inputcode (); Numbercup+=m;                        Showallbuygoods ();  Break;  Case3: System.out.println ("Please Enter quantity:");            Inputcode (); Numberrubber+=m;            Showallbuygoods ();  Break;  Case4: System.exit (1);  Break; default:             Break; }    }    /**user Input Product code function*/     Public voidInputcode () {Scanner Scann=NewScanner (system.in); M=Scann.nextint (); }    /**Show items that have been purchased*/     Public voidShowallbuygoods () {Allprice= Numbercup * 5 + numberpen * 3 + numberrubber * 2 ; System.out.println ("You chose the" +numberpen+ "only pen," +numbercup+ "a water Cup," +numberrubber+ "eraser, altogether" +allprice+ "yuan. Do you need anything else, please enter 1, please enter 2.");            Isgoon (); }    /**See if the user continues*/     Public voidIsgoon () {Scanner Scann=NewScanner (system.in); M=Scann.nextint (); if(M = = 1) {showallgoods (); }Else if(M = = 2) {            //TODOAllprice = Numbercup * 5 + numberpen * 3 + numberrubber * 2 ;        Buy (Allprice); }Else{System.out.println ("Input is incorrect, please re-enter.");        Isgoon (); }    }    /**buy function*/     Public voidBuyinta) {        if(A > 100) {System.out.println ("The selected item is more than 100 yuan, please delete:");        Deletegoods (); }Else{System.out.println ("The payment was successful."); }    }    /**Delete Item*/     Public voidDeletegoods () {System.out.println ("1. Pen 2. Water Cup 3. Eraser"); Scanner Scanner=NewScanner (system.in); intj =Scanner.nextint (); Switch(j) { Case1: System.out.println ("Please Enter quantity:");           Inputcode (); Numberpen-=m;                       Showallbuygoods ();  Break;  Case2: System.out.println ("Please Enter quantity:");            Inputcode (); Numbercup-=m;            Showallbuygoods ();  Break;  Case3: System.out.println ("Please Enter quantity:");            Inputcode (); Numberrubber-=m;            Showallbuygoods ();  Break;  Case4: System.exit (1);  Break; default:             Break; }}}

Java version-----Store shopping System

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.