真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

消費金額的java代碼 消費金額的java代碼是什么

java超市計價系統(tǒng)代碼

package?entity;

創(chuàng)新互聯(lián)服務(wù)緊隨時代發(fā)展步伐,進行技術(shù)革新和技術(shù)進步,經(jīng)過十余年的發(fā)展和積累,已經(jīng)匯集了一批資深網(wǎng)站策劃師、設(shè)計師、專業(yè)的網(wǎng)站實施團隊以及高素質(zhì)售后服務(wù)人員,并且完全形成了一套成熟的業(yè)務(wù)流程,能夠完全依照客戶要求對網(wǎng)站進行網(wǎng)站設(shè)計制作、做網(wǎng)站、建設(shè)、維護、更新和改版,實現(xiàn)客戶網(wǎng)站對外宣傳展示的首要目的,并為客戶企業(yè)品牌互聯(lián)網(wǎng)化提供全面的解決方案。

public?class?Market?{

private?int?id;//id

private?int?num;//數(shù)量

private?String?goods;//商品

private?double?price;//價格

public?Market(int?id,?int?num,?String?goods,?double?price)?{

super();

this.id?=?id;

this.num?=?num;

this.goods?=?goods;

this.price?=?price;

}

public?int?getId()?{

return?id;

}

public?void?setId(int?id)?{

this.id?=?id;

}

public?int?getNum()?{

return?num;

}

public?void?setNum(int?num)?{

this.num?=?num;

}

public?String?getGoods()?{

return?goods;

}

public?void?setGoods(String?goods)?{

this.goods?=?goods;

}

public?double?getPrice()?{

return?price;

}

public?void?setPrice(double?price)?{

this.price?=?price;

}

public?double?calc(?){

double?sum=price*num;

System.out.println("您消費共計:"+sum+"¥");

return?sum;

}

}

package?test;

import?java.util.HashMap;

import?java.util.Map;

import?java.util.Scanner;

import?entity.Market;

public?class?Test?{

private?static?MapInteger,Market?goods=new?HashMapInteger,?Market();

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

System.out.println("-------超市計價系統(tǒng)-------");

String?goods1="可口可樂";

String?goods2="爆米花";

String?goods3="益達";

printTable("編號","商品","價格");

printTable("1",goods1,"3.0¥");

printTable("2",goods2,"5.0¥");

printTable("3",goods3,"10.0¥");

goods.put(1,?new?Market(1,?1,?goods1,?3.0));

goods.put(2,?new?Market(2,?1,??goods2,?5.0));

goods.put(3,?new?Market(3,?1,?goods3,?10.0));

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

System.out.println("請輸入商品的編號:");

int?num?=?input.nextInt();

System.out.println("請輸入商品的數(shù)量");

int?amount?=?input.nextInt();

Market?market?=?goods.get(num);

market.setNum(amount);

market.calc();

}

private?static?void?printTable(String?row1,String?row2,String?row3?)?{

System.out.print(row1);

int?times=12;

if?(row2!="商品")?{

times=5;

}

for?(int?i?=?0;?i??times;?i++)?{

System.out.print("?");

}

System.out.print(row2);

for?(int?i?=?0;?i??10;?i++)?{

System.out.print("?");

}

System.out.print(row3);

System.out.println("\n");

}

}

//測試結(jié)果:

-------超市計價系統(tǒng)-------

編號????????????商品??????????價格

1?????可口可樂??????????3.0¥

2?????爆米花??????????5.0¥

3?????益達??????????10.0¥

請輸入商品的編號:

3

請輸入商品的數(shù)量

5

您消費共計:50.0¥

Java編寫程序計算打折后金額

public static void main(String[] args) {

double amount = 1200;// 消費金額

boolean isTeacherOrOld = true; // 是否有教師資格證或者老人標(biāo)識

BigDecimal discountEightFive = new BigDecimal("0.85");// 85折

BigDecimal discountNine = new BigDecimal("0.9");// 95折

BigDecimal discountNineFive = new BigDecimal("0.95");// 95折

BigDecimal bdAmount = new BigDecimal(Double.toString(amount));

BigDecimal calcAmount = new BigDecimal("0.00");

if (amount = 2000) {

calcAmount = bdAmount.multiply(discountEightFive);

} else if (amount 1000 amount 2000) {

calcAmount = bdAmount.multiply(discountNine);

} else {

calcAmount = new BigDecimal(Double.toString(amount));

}

if (isTeacherOrOld amount = 1000) {

System.out.println("消費金額:" + calcAmount.multiply(discountNineFive).toString());

} else {

System.out.println("消費金額:" + calcAmount.toString());

}

}

java代碼

import java.util.Scanner;

/**

* @author a href="mailto:116982086@qq.com"/a

*/

public class Demo {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.println("請輸入消費金額");

double sum = scanner.nextDouble();

String what = null;

// 如果消費金額大于50才提示換購

if (sum = 50) {

System.out.println("是否參加優(yōu)惠換購活動:");

System.out.println("1:滿50元,加2元換購百事可樂飲料一瓶");

if (sum = 100) {

System.out.println("2:滿100元,加3元換購500ml可樂一瓶");

System.out.println("3:滿100元,加3元換購500ml可樂一瓶");

}

if (sum = 200) {

System.out.println("4:滿200元,加10元可換購1歌蘇泊爾炒菜鍋");

System.out.println("5:滿200元,加20元可換購歐萊雅爽膚水一瓶");

}

System.out.println("0:不換購");

System.out.println("請選擇:");

int choice = scanner.nextInt();

int add = 0;

switch (choice) {

case 1:

add = 2;

what = "500ml可樂一瓶";

break;

case 2:

add = 3;

what = "500ml可樂一瓶";

break;

case 3:

add = 3;

what = "5公斤面粉";

break;

case 4:

add = 10;

what = "一個歌蘇泊爾炒菜鍋";

break;

case 5:

add = 20;

what = "歐萊雅爽膚水一瓶";

break;

default:

break;

}

sum += add;

}

System.out.println("本次消費總金額: " + sum);

if (null != what) {

System.out.println("成功換購 " + what);

}

}

}

用java寫出商品打折程序

嘗試解答一下,這個里面還有老年和教師的判斷就省略,主要是打折的代碼

import?java.util.Scanner;

class?Test{

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

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

System.out.println("請輸入消費的金額:");

double?oldprice?=?sc.nextDouble();

double?newprice;

if(oldprice?=?2000){

newprice?=?oldprice?*?0.85;

}else?if(oldprice?=?1000??oldprice??2000){

newprice?=?oldprice?*?0.9;

}else

newprice?=?oldprice;

Judge?jud?=?new?Judge();

if(jud.isTeacher()||?jud.isOldman())

newprice?=?newprice?*?0.95;

System.out.println("打折后的價格是:"?+?newprice);

System.out.println("折扣的程度是:?"?+?newprice?/?oldprice);

}

}

class?Judge{

public?boolean?isTeacher(){

boolean?isTeacher?=?false;

return?isTeacher;

}

public?boolean?isOldman(){

boolean?isOld?=?false;

return?isOld;

}

}

今天剛學(xué)的,用java實現(xiàn)輸入任意金額,達到用戶想知道什么信息就知道什么信息,

publicintgetMaxRepeatTime(Strings){inttime=0;String[]list=s.split("");for(Stringtemp:list){intcount=0;for(Stringi:list){if(temp.equals(i)){count+=1;}}if(counttime){time=count;}}returntime;}這個方法可以獲取某個輸入字符串中重復(fù)最多字符的重復(fù)數(shù)。你可以按你的需要進行修改,獲得這個字符,或者是獲得指定字符重復(fù)的次數(shù)等等。。你早點把題目說清楚嘛。。你這個需求就更簡單了:publicStringgetRepeatChar(Strings){Stringoutput="";String[]list=s.split("");for(Stringtemp:list){intcount=0;for(Stringi:list){if(temp.equals(i)){count+=1;}}if(count1){output+=temp+"";}}returnoutput;}

編寫一個java消費單算出折扣怎么寫如圖

沒有理解你的問題,是想打印出圖上的效果,還是說告訴我原價和折后價讓我算折扣?


文章題目:消費金額的java代碼 消費金額的java代碼是什么
鏈接分享:http://weahome.cn/article/dodssic.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部