當前位置:首頁 » 團購打折 » 根據月份打折的程序怎麼編寫

根據月份打折的程序怎麼編寫

發布時間: 2021-03-07 00:23:10

Ⅰ 用java寫出商品打折程序

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

importjava.util.Scanner;

classTest{
publicstaticvoidmain(String[]args){
Scannersc=newScanner(System.in);

System.out.println("請輸入消費的金額:");
doubleoldprice=sc.nextDouble();
doublenewprice;
if(oldprice>=2000){
newprice=oldprice*0.85;
}elseif(oldprice>=1000&&oldprice<2000){
newprice=oldprice*0.9;
}else
newprice=oldprice;
Judgejud=newJudge();
if(jud.isTeacher()||jud.isOldman())
newprice=newprice*0.95;

System.out.println("打折後的價格是:"+newprice);
System.out.println("折扣的程度是:"+newprice/oldprice);
}

}
classJudge{
publicbooleanisTeacher(){
booleanisTeacher=false;
returnisTeacher;
}
publicbooleanisOldman(){
booleanisOld=false;
returnisOld;
}
}

Ⅱ 1.請根據下列描述編寫購物優惠程序。

體上添加兩個文本框和一個命令按鈕,要求在Text1中輸入購物商品總金額,單

Ⅲ java打折程序,有幾個不明白,能幫忙寫下源代碼嗎

import java.util.*;
public class dazhe{
public static void main(String[] arg0){
Scanner in=new Scanner(System.in);
String huiyuan;double jiner;
System.out.println("***************打折系統**************:");
System.out.println("請輸入是否是會員:是(y)/否(其他字元)");
huiyuan=in.next();
System.out.println("請輸入購物金額");
jiner=in.nextDouble();
.out.println((int)jiner);
if(huiyuan=="y")
{
if(jiner>=100&jiner<=200)
{ jiner=jiner*0.8;
System.out.println("實付金額:");
System.out.println((int)jiner);}
else if(jiner>200)
{
jiner=jiner*0.75;
System.out.println("實付金額:");
System.out.println((int)jiner);
}

else if(jiner>=100)
{
jiner=jiner*0.85;
System.out.println("實付金額:");
System.out.println(jiner);}
}
else {System.out.println("實付金額:");
System.out.println(jiner);}

}

}

Ⅳ c語言 如何用switch語句編寫一個有關商場購物金額優惠的選擇程序

#include <stdio.h>

int main(int argc, char** argv)
{
int amount = 0;
scanf("%d", &amount);//輸入顧客購買的總額
int status = amount/1000;
switch (status)
{
case 0: break;
case 1: amount = amount * 0.95; break;
case 2: amount = amount*0.90; break;
case 3: amount *= 0.85; break;
default: amount *= 0.80; break;
}
printf("%d\n", amount);//列印專出打折後屬的總額

return 0;
}

Ⅳ 用C語言寫一個打折程序.如圖所示

#include<stdio.h>

intmain()
{
intx;
floaty;
printf("請輸入本次消費的金額: ");
scanf("%d",&x);
if(x>=1000)
y=x*0.85;
elseif(500<=x&&x<1000)
y=0.9*x;
elseif(300<=x&&x<500)
y=0.96*x;
elseif(x<300&&x>0)
y=x;
printf("實際花費的金額:%.2f",y);
return0;
}

Ⅵ 飛機票打折程序怎麼寫

import java.util.Scanner;

public class BuyFeiJiPiao{

public void buyNum(int num){
if(0< num && num <= 10){
System.out.println("價格:¥"+(1000*num*0.9));
}else if(10 < num && num <= 20){
System.out.println("價格:¥"+(1000*num*0.8));
}else{
System.out.println("價格:¥"+(1000*num*0.7));
}
}

public void buyDaZe(int num){
switch (num) {
case 9:
System.out.println("打折數量范圍:1 - 10");
break;
case 8:
System.out.println("打折數量范圍:11 - 20");
break;
case 7:
System.out.println("打折數量大於20張");
break;

default:
break;
}
}

public static void main(String[] args) {
BuyFeiJiPiao b = new BuyFeiJiPiao();
Scanner sc = new Scanner(System.in);
System.out.print("請輸入購買的票數:");
String num = sc.next();
b.buyNum(Integer.parseInt(num));
System.out.print("請輸入折扣:");
String n = sc.next();
b.buyDaZe(Integer.parseInt(n));
}

}

Ⅶ EXCEL怎麼編寫自動打折程序

如圖,折後價=原價×折率,在E2輸入公式:=C2*D2,即得到折後價;
滑鼠移到E2右下角填充柄(黑色小方塊)處雙擊或按住滑鼠向下拖動,即可填充公式並顯示出計算結果。

Ⅷ python買東西打折的程序怎麼做

通過if else 邏輯判斷就行了

Ⅸ 用java編寫一個程序,從鍵盤上輸入某種商品名稱,單價的折扣率,輸出該商品打折後的價格,要求使用

package box1;

import java.util.Scanner;

public class qc {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
String c="";
double d=0.0;double e=0.0;
System.out.println("請輸入商品名稱:版");
c=input.next();
System.out.println("請輸入商品折權扣率:");
d=input.nextDouble();
System.out.println("請輸入商品原價:");
e=input.nextDouble();
System.out.println("商品打折後的價格:" +e*d);

}
技術有限 謝謝採納

熱點內容
斷背山有幾分鍾 發布:2024-08-19 08:31:17 瀏覽:253
日本電影 女老師和學生私奔 發布:2024-08-19 08:29:36 瀏覽:49
台灣電影 雙胞胎 發布:2024-08-19 08:02:18 瀏覽:134
2020最新電影在線觀看網站 發布:2024-08-19 07:56:06 瀏覽:641
男男電影虐 發布:2024-08-19 07:04:57 瀏覽:10
韓國電影李采潭主演的關於發廊的 發布:2024-08-19 07:01:57 瀏覽:2
每期都有做的動漫 發布:2024-08-19 06:44:33 瀏覽:778
東宮拍攝時間 發布:2024-08-19 06:44:12 瀏覽:5
林正英電影情節鬼抬轎 發布:2024-08-19 06:36:35 瀏覽:254
懂的都懂在線觀看網站 發布:2024-08-19 06:26:11 瀏覽:676