求java代码 , 关于会员折扣的boolean user=true;
double jg=100;
int xfcount;
三个变量自己决定
if(user){
jg*0.9;
}
if(user==falsexfcount200){
jg*0.9;
}
if(user==truexfcount200){
jg*0.8;
}
用java写出商品打折程序尝试解答一下java程序代码打折,这个里面还有老年和教师的判断就省略,主要是打折的代码
import java.util.Scanner;
class Test{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("请输入消费的金额java程序代码打折:");
double oldprice = sc.nextDouble();
double newprice;
if(oldprice = 2000){
newprice = oldprice * 0.85;
}else if(oldprice = 1000oldprice2000){
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;
}
}
Java编写程序计算打折后金额public static void main(String[] args) {
double amount = 1200;// 消费金额
boolean isTeacherOrOld = true; // 是否有教师资格证或者老人标识
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 (amount1000amount2000) {
calcAmount = bdAmount.multiply(discountNine);
} else {
calcAmount = new BigDecimal(Double.toString(amount));
}
if (isTeacherOrOldamount = 1000) {
System.out.println("消费金额:" + calcAmount.multiply(discountNineFive).toString());
} else {
System.out.println("消费金额:" + calcAmount.toString());
}
}
求大神帮忙,谢谢?。。。。。ㄒ狫ava代码)//第一题java程序代码打折的答案java程序代码打折:
import java.util.Scanner;
public class test {
public static void main(String[] args)
{
System.out.println("输入购买金额java程序代码打折:");
Scanner input=new Scanner(System.in);
double a=input.nextDouble();
System.out.println("输入顾客类型(会员或普通)java程序代码打折:");
String b=input.next();
if(b=="会员")
【java程序代码打折 java程序代码大全】{
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; i3; i++)
{
for(int x = i + 1; x3; x++)
{
System.out.print(" ");
}
for(int y = 0; y(i + 1) * 2 - 1; y++)
{
System.out.print("*");
}
System.out.println();
}
for(int i = 0; i4; i++)
{
for(int x = 0; xi; x++)
{
System.out.print(" ");
}
for(int y = i; y2 * 4 - i - 1; y++)
{
System.out.print("*");
}
推荐阅读
- 飞行堡垒7游戏文件夹下载,飞行堡垒7的应用商店在哪
- u盘模式怎么转换为usb模式的简单介绍
- pg数据库有回滚吗,数据库的回滚机制原理
- 服务器压力,服务器压力过大,请稍后再试?
- php获取不到小程序数据 php获取微信小程序用户信息
- 视频号直播投流怎么收费,视频号直播怎么投流
- gis软件流程,gis教程视频
- 抖音橱窗视频是什么,抖音短视频橱窗
- linux显示字符串命令 linux 字符串命令