Android Training Lesson two homework exercises

Source: Internet
Author: User

/*

1, please use Scanner,while,if,switch to make a simple order and can checkout the small system;

Requirements: To do the following functions;

(1) Ordering menu;

(2) Order quantity;

(3) Checkout;

(4) Exit;

*/

Package Org.lyk;


Import Java.util.Scanner;


public class Dianc {

static int dpdf = 10;//Dongpo Tofu Price

static int JBRP = 15;//Pepper Fried meat price

static int sxpg = 10;//Garlic Ribs Price

static int scy = 25;//Sauerkraut Fish Price

static int szrp = 35;//boiled meat price

static int HSPG = 20;//braised Pork ribs price

static int sl;//Order quantity

static int sum1,sumdp;//Dongpo Tofu Total Price

static int sum2,sumjb;//pepper sliced pork lump sum

static int sum3,sumsx;//Garlic Ribs Total Price

static int sum4,sumsc;//Sauerkraut Fish Total Price

static int sum5,sumsz;//Total water boiled meat

static int sum6,sumhs;//Braised pork Ribs Total Price

static int sum;//Total Price


Enter Order quantity

public static void Shuliang () {

Scanner s = new Scanner (system.in);

SL = S.nextint ();

}


Menu

public static void Caidan () {

System.out.println ("Welcome to the ordering system!") ");

System.out.println ("Please follow the menu for order ordering! ");

System.out.println ("1. Dongpo Tofu" + dpdf + "Yuan" + "2. Fried sliced Pork" + JBRP + "Yuan"+ "3. Garlic Pork Ribs" + sxpg + "Yuan "+" \ n "+" 4. Pickled Cabbage fish "+ scy +" Yuan "+" 5. Boiled sliced meat "+ szrp +" Yuan "+" 6. Braised pork Ribs "+ Hspg +" Yuan ");

System.out.println ("Press 0 to exit a la carte checkout!") ");

}


public static void Main (string[] args) {

Caidan ();

Scanner s = new Scanner (system.in);

int I=s.nextint ();

Boolean A = true;

while (a) {

int i = S.nextint ();

switch (i) {

Case 0:

System.out.println ("Exit à la carte, checkout!");

Calculate total consumption price

sum = SUMDP + sumjb + sumsx + sumsc + sumsz + SUMHS;

System.out.println ("Total consumption:" + sum + "Yuan");

A = false;

Break

Case 1:

System.out.println ("Your point is Dongpo tofu. Please confirm the number of copies!");

Shuliang ();

SUM1 = dpdf * SL;

SUMDP+=SUM1;

System.out.println ("Dongpo tofu" + SL + "share," + sum1 + "Yuan");

System.out.println ("Continue to order, or press 0 to exit a la carte checkout");

Break

Case 2:

System.out.println ("Your point is fried sliced pork, please confirm the number of copies");

Shuliang ();

sum2 = JBRP * SL;

sumjb+=sum2;

SYSTEM.OUT.PRINTLN ("Fried sliced pork" + SL + "share," + sum2 + "Yuan");

System.out.println ("Continue to order, or press 0 to exit a la carte checkout");

Break

Case 3:

SYSTEM.OUT.PRINTLN ("Your order is garlic ribs. Please confirm the number of copies");

Shuliang ();

SUM3 = SXPG * SL;

SUMSX+=SUM3;

System.out.println ("Garlic ribs" + SL + "share," + sum3 + "Yuan");

System.out.println ("Continue to order, or press 0 to exit a la carte checkout");

Break

Case 4:

SYSTEM.OUT.PRINTLN ("Your order is pickled cabbage fish. Please confirm the number of copies");

Shuliang ();

SUM4 = Scy * SL;

SUMSC+=SUM4;

System.out.println ("Pickled cabbage fish" + sl + "share," + sum4 + "Yuan");

System.out.println ("Continue to order, or press 0 to exit a la carte checkout");

Break

Case 5:

System.out.println ("Your point is boiled sliced meat, please confirm the number of copies");

Shuliang ();

SUM5 = SZRP * SL;

SUMSZ+=SUM5;

System.out.println ("Boiled sliced meat" + SL + "share," + SUM5 + "Yuan");

System.out.println ("Continue to order, or press 0 to exit a la carte checkout");

Break

Case 6:

SYSTEM.OUT.PRINTLN ("Your order is braised ribs. Please confirm the number of copies");

Shuliang ();

SUM6 = HSPG * SL;

SUMHS+=SUM6;

System.out.println ("Braised ribs" + SL + "share," + Sum6 + "Yuan");

System.out.println ("Continue to order, or press 0 to exit a la carte checkout");

Break

}

}

}

}

There are still many shortcomings to be improved in beginners ...

This article is from the "Kun" blog, please be sure to keep this source http://linyingkun.blog.51cto.com/2393912/1571003

Android Training Lesson two homework exercises

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.