
正文
java程序代码打折 java程序代码大全
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
求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;
}
相关问答
Q1: 用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 = 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;
}
}
Q2: 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 (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());
}
}
Q3: 求大神帮忙,谢谢!!!!!(要Java代码)
//第一题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=="会员")
{
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();
}
}
}
Q4: 我有道java编程小题求编程:商场价格打折 无需界面
写一个简单点java程序代码打折的商品类Product
属性有
String pName;
double pPrice;
int pPiscount;//打折范围1-9
然后写一个业务,购买商品,添加到一个List集合.
结账的时候,java程序代码打折你自己选5个要求中的其中一个,并且在业务方法里面实现这5个需求.........
Q5: java编写 超市大优惠满800元以上输出打6折,满600元以上输出打7折,满400元
public static void main(String[] args) {
// 消费金额
int amount = 0;
if(amount = 800) {
System.out.println("打6折");
}
else if(amount = 600) {
System.out.println("打7折");
}
else if(amount = 400) {
System.out.println("打8折");
}
else if(amount = 200) {
System.out.println("打9折");
}
else {
System.out.println("不打折");
}
}
java程序代码打折的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java程序代码大全、java程序代码打折的信息别忘了在本站进行查找喔。








