欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java客戶購買東西代碼,java如何實現(xiàn)多種商品購買

求大神幫忙,謝謝!!!!!(要Java代碼)

//第一題的答案:

我們提供的服務(wù)有:成都網(wǎng)站設(shè)計、網(wǎng)站制作、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、云巖ssl等。為1000+企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的云巖網(wǎng)站制作公司

import?java.util.Scanner;

public?class?test?{

public?static?void?main(String[]?args)

{

System.out.println("輸入購買金額:");

Scanner?input=new?Scanner(System.in);

double?a=input.nextDouble();

System.out.println("輸入顧客類型(會員或普通):");

String?b=input.next();

if(b=="會員")

{

if(a=100)

{

a=a*0.8;

System.out.println("需付款:"+a);

}

else

{

System.out.println("需付款:"+a);

}

}

if(b=="普通")

{

if(a=200)

{

a=a*0.75;

System.out.println("需付款:"+a);

}

else

{

System.out.println("需付款:"+a);

}

}

}

}

//下面是第二題答案:

public?class?test?{

public?static?void?main(String[]?args)

{ ???????????

for(int?i?=?0;?i??3;?i++)?

{?

for(int?x?=?i?+?1;?x??3;?x++)?

{?

System.out.print("?");?

}?

for(int?y?=?0;?y??(i?+?1)?*?2?-?1;?y++)?

{?

System.out.print("*");?

}?

System.out.println();?

}?

for(int?i?=?0;?i??4;?i++)?

{?

for(int?x?=?0;?x??i;?x++)?

{?

System.out.print("?");?

}?

for(int?y?=?i;?y??2?*?4?-?i?-?1;?y++)?

{?

System.out.print("*");?

}?

System.out.println();?

}

}

}

使用JAVA 編寫一個程序,顯示5中商品價格,用戶可以選擇多種商品并在其后的文本框輸入購買的數(shù)量。

用java Swing做的?給你個代碼,還有運行結(jié)果圖

package?my.test.main;

import?java.awt.BorderLayout;

import?java.awt.EventQueue;

import?java.awt.event.ActionEvent;

import?java.awt.event.ActionListener;

import?java.awt.event.ComponentEvent;

import?java.awt.event.ComponentListener;

import?java.awt.event.KeyAdapter;

import?java.awt.event.KeyEvent;

import?java.awt.event.KeyListener;

import?javax.swing.JFrame;

import?javax.swing.JPanel;

import?javax.swing.SwingUtilities;

import?javax.swing.border.EmptyBorder;

import?javax.swing.event.AncestorEvent;

import?javax.swing.event.AncestorListener;

import?javax.swing.event.CaretEvent;

import?javax.swing.event.CaretListener;

import?javax.swing.JLabel;

import?javax.swing.JTextField;

public?class?Purchase?extends?JFrame?{

private?JPanel?contentPane;

private?JTextField?textField;

private?JTextField?textField_1;

private?JTextField?textField_2;

private?JTextField?textField_3;

private?JTextField?textField_4;

private?JLabel?label_9;

/**

?*?Launch?the?application.

?*/

public?static?void?main(String[]?args)?{

EventQueue.invokeLater(new?Runnable()?{

public?void?run()?{

try?{

Purchase?frame?=?new?Purchase();

frame.setVisible(true);

}?catch?(Exception?e)?{

e.printStackTrace();

}

}

});

}

/**

?*?Create?the?frame.

?*/

public?Purchase()?{

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setBounds(100,?100,?450,?300);

contentPane?=?new?JPanel();

contentPane.setBorder(new?EmptyBorder(5,?5,?5,?5));

setContentPane(contentPane);

contentPane.setLayout(null);

JLabel?label?=?new?JLabel("\u5546\u54C11");

label.setBounds(56,?40,?54,?15);

contentPane.add(label);

JLabel?label_1?=?new?JLabel("\u5546\u54C12");

label_1.setBounds(56,?70,?54,?15);

contentPane.add(label_1);

JLabel?label_2?=?new?JLabel("\u5546\u54C13");

label_2.setBounds(56,?100,?54,?15);

contentPane.add(label_2);

JLabel?label_3?=?new?JLabel("\u5546\u54C14");

label_3.setBounds(56,?130,?54,?15);

contentPane.add(label_3);

JLabel?label_4?=?new?JLabel("\u5546\u54C15");

label_4.setBounds(56,?160,?54,?15);

contentPane.add(label_4);

JLabel?label_5?=?new?JLabel("\u5546\u54C1\u540D\u79F0");

label_5.setBounds(56,?7,?54,?15);

contentPane.add(label_5);

JLabel?label_6?=?new?JLabel("單價");

label_6.setBounds(179,?7,?54,?15);

contentPane.add(label_6);

JLabel?label_7?=?new?JLabel("數(shù)量");

label_7.setBounds(307,?7,?54,?15);

contentPane.add(label_7);

JLabel?label_8?=?new?JLabel("總價");

label_8.setBounds(145,?224,?54,?15);

contentPane.add(label_8);

label_9?=?new?JLabel("0");

label_9.setBounds(209,?224,?54,?15);

contentPane.add(label_9);

JLabel?label_10?=?new?JLabel("10");

label_10.setBounds(185,?40,?54,?15);

contentPane.add(label_10);

JLabel?label_11?=?new?JLabel("20");

label_11.setBounds(185,?70,?54,?15);

contentPane.add(label_11);

JLabel?label_12?=?new?JLabel("30");

label_12.setBounds(185,?100,?54,?15);

contentPane.add(label_12);

JLabel?label_13?=?new?JLabel("40");

label_13.setBounds(185,?130,?54,?15);

contentPane.add(label_13);

JLabel?label_14?=?new?JLabel("50");

label_14.setBounds(185,?160,?54,?15);

contentPane.add(label_14);

textField?=?new?JTextField();

textField.setBounds(295,?37,?66,?21);

contentPane.add(textField);

textField.setColumns(10);

textField.addKeyListener(new?CalcTotle());

textField_1?=?new?JTextField();

textField_1.setColumns(10);

textField_1.setBounds(295,?67,?66,?21);

contentPane.add(textField_1);

textField_1.addKeyListener(new?CalcTotle());

textField_2?=?new?JTextField();

textField_2.setColumns(10);

textField_2.setBounds(295,?97,?66,?21);

contentPane.add(textField_2);

textField_2.addKeyListener(new?CalcTotle());

textField_3?=?new?JTextField();

textField_3.setColumns(10);

textField_3.setBounds(295,?127,?66,?21);

contentPane.add(textField_3);

textField_3.addKeyListener(new?CalcTotle());

textField_4?=?new?JTextField();

textField_4.setColumns(10);

textField_4.setBounds(295,?157,?66,?21);

contentPane.add(textField_4);

textField_4.addKeyListener(new?CalcTotle());

}

class?CalcTotle?extends?KeyAdapter?{

@Override

public?void?keyReleased(KeyEvent?e)?{

//?TODO?Auto-generated?method?stub

int?count1,?count2,?count3,?count4,?count5;

if?(!textField.getText().isEmpty())?{

count1?=?Integer.parseInt(textField.getText())?*?10;

}?else?{

count1?=?0;

}

if?(!textField_1.getText().isEmpty())?{

count2?=?Integer.parseInt(textField_1.getText())?*?20;

}?else?{

count2?=?0;

}

if?(!textField_2.getText().isEmpty())?{

count3?=?Integer.parseInt(textField_2.getText())?*?30;

}?else?{

count3?=?0;

}

if?(!textField_3.getText().isEmpty())?{

count4?=?Integer.parseInt(textField_3.getText())?*?40;

}?else?{

count4?=?0;

}

if?(!textField_4.getText().isEmpty())?{

count5?=?Integer.parseInt(textField_4.getText())?*?50;

}?else?{

count5?=?0;

}

final?int?totle?=?count1?+?count2?+?count3?+?count4?+?count5;

SwingUtilities.invokeLater(new?Runnable()?{

@Override

public?void?run()?{

//?TODO?Auto-generated?method?stub

label_9.setText(totle?+?"");

}

});

}

}

}

java 如何實現(xiàn)一個用戶 一個訂單

package cn.test.logan.day04;

import java.util.ArrayList;

/**

* 訂單類

* 包含:訂單ID、訂單所屬用戶、訂單所包含的商品、訂單總金額、訂單應(yīng)付金額

* 500-1000 ------- 8.5折

* 1000-1500 ------- 8折

* 1500-2000 ------- 7折

* 2000以上 ------- 6.5折

* 如果是會員,那么可以基于以上折扣繼續(xù)折扣

* 一般會員:9.5折

* 中級會員:9折

* 高級會員:8折

* @author QIN

*

*/

public class Order {undefined

// 訂單ID

public String ordId;

// 訂單所屬用戶

public User user;

// 訂單所包含的商品(多個商品,使用ArrayList)

public ArrayList pds;

// 訂單總金額

public float ordAllAmt;

// 訂單應(yīng)付金額

public float payAmt;

// 計算總金額的方法

public void setAllAmt() {undefined

float sum = 0;

for(int i=0;i

sum +=this.pds.get(i).price * this.pds.get(i).number;

}

this.ordAllAmt = sum;

}

// 計算實付金額

public void setPayAmt() {undefined

float tmp = this.ordAllAmt;

// 根據(jù)總金額進(jìn)行折扣

if(this.ordAllAmt = 500 this.ordAllAmt 1000) {undefined

tmp = this.ordAllAmt * 0.85f;

}

if(this.ordAllAmt = 1000 this.ordAllAmt 1500) {undefined

tmp = this.ordAllAmt * 0.8f;

}

if(this.ordAllAmt = 1500 this.ordAllAmt 2000) {undefined

tmp = this.ordAllAmt * 0.7f;

}

if(this.ordAllAmt = 2000) {undefined

tmp = this.ordAllAmt * 0.65f;

}

// 根據(jù)會員等級折扣

if(user.CustLevel.equals("一般會員")) {undefined

tmp = tmp * 0.95f;

}

if(user.CustLevel.equals("中級會員")) {undefined

tmp = tmp * 0.9f;

}

if(user.CustLevel.equals("高級會員")) {undefined

tmp = tmp * 0.8f;

}

//計算結(jié)果賦值給對象上的payAmt變量

this.payAmt = tmp;

}

}

參考資料來源:百度貼吧CSDN博主「公子京」

用JAVA編寫購物系統(tǒng)的代碼是什么?(急)

算是最簡單的吧

package cn.job01;

import java.util.Scanner;

public class Lx07 {

public static void choice() {

System.out.println("登陸菜單 ");

System.out.println("1登陸系統(tǒng)");

System.out.println("2退出");

}

static void choice1() {

System.out.println("購物管理系統(tǒng)客戶信息");

System.out.println("1顯示所有客戶信息");

System.out.println("2添加客戶信息");

System.out.println("3修改客戶信息");

System.out.println("4查詢客戶信息");

}

static void choice2() {

System.out.println("購物管理系統(tǒng)真情回饋");

System.out.println("1幸運大放送");

System.out.println("2幸運抽獎");

System.out.println("3生日問候");

}

public static void main(String[] args) {

choice();

Scanner input = new Scanner(System.in);

System.out.println("請輸入1or2");

int num = input.nextInt();

switch (num) {

case 1:

System.out.println("主菜單");

System.out.println("1客戶信息管理");

System.out.println("2購物結(jié)算");

System.out.println("3真情回饋");

System.out.println("4注銷");

break;

}

System.out.println("選擇輸入數(shù)字");

int num1 = input.nextInt();

switch (num1) {

case 1:

choice1();

break;

case 2:

System.out.println("購物結(jié)算");

break;

case 3:

choice2();

break;

case 4:

choice();

break;

}

}

}

編寫java代碼要求顧客輸入購買多少斤當(dāng)用戶輸入為10斤以內(nèi),則輸出用戶應(yīng)支付金額?

2、public class Test11 {

public static void main(String[] args) {

System.out.println("滯貿(mào)旅客的人數(shù)" + (1189 - 108*10) );

}

}

3、public class Test11 {

public static void main(String[] args) {

try {

Scanner scanner = new Scanner(System.in);

System.out.print("輸入購買雞蛋(斤):");

int number = scanner.nextInt();

if(number10){

throw new RuntimeException("不允許購買這么多!");

}

else {

System.out.println("用戶應(yīng)支付金額"+number*3.98);

}

}

catch (Exception e){

System.out.println(e.getMessage());

}

}

}

網(wǎng)站標(biāo)題:java客戶購買東西代碼,java如何實現(xiàn)多種商品購買
URL地址:http://chinadenli.net/article11/dsiiogd.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)定制網(wǎng)站小程序開發(fā)網(wǎng)站維護(hù)外貿(mào)網(wǎng)站建設(shè)企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)