java机票打折代码 航空公司折扣代码
使用java程序编写下面3个题
第一个:
十年的宁洱网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销的优势是能够根据用户设备显示端的尺寸不同,自动调整宁洱建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“宁洱网站设计”,“宁洱网站推广”以来,每个客户项目都认真落实执行。
import java.util.Scanner;
/**
* Created by Chen on 2015/11/11.
*/
public class T {
public static void main(String[] args) {
int temp = 0;
Scanner s = new Scanner(System.in);
System.out.print("请输入3个整数");
int a = s.nextInt();
int b = s.nextInt();
int c = s.nextInt();
if (a b) {
temp = a;
a = b;
b = temp;
}
if (a c) {
temp = a;
a = c;
c = temp;
}
if (b c) {
temp = b;
b = c;
c = temp;
}
System.out.println("a的值:" + a + "b的值:" + b + "c的值:" + c);
}
}
第二题:
import java.util.Scanner;
/**
* Created by Chen on 2015/11/11.
*/
public class T {
public static void main(String[] args) {
int temp = 0;
Scanner s = new Scanner(System.in);
System.out.print("输入一个数");
int a = s.nextInt();
if((a%3==0)||(a%5==0))
System.out.println("该整数是3或5的倍数");
else System.out.println("“该数不能被3或5中的任何一个数整除" );
}
}
第三题:
import java.util.Scanner;
/**
* Created by Chen on 2015/11/11.
*/
public class T {
public static void main(String[] args) {
int price = 5000;
Scanner s = new Scanner(System.in);
System.out.print("输入订票月份:");
int month = s.nextInt();
if (month 0 month 13) {
if (month 3 month 11) {
System.out.println("该月车票价格如下:头等舱" + price * 0.9 + "元" + " " + "经济舱" + price * 0.8);
} else System.out.println("该月车票价格如下:头等舱" + price * 0.5 + "元" + " " + "经济舱" + price * 0.4);
} else System.out.println("请输入正确的月份");
}
}
java编程,机票例题纠正改错,谢谢
在你的基础上稍稍改动:
import java.util.Scanner;
public class JiPiao {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入您要出行的月份:");
int YueFen = input.nextInt();
System.out.println("请问您选择头等舱还是经济舱?头等舱输入1,经济舱输入2");
int XuanZe = input.nextInt();
if (XuanZe == 1 || XuanZe == 2) {
} else {
System.out.println("请输入数字1,2");
}
double JiaGe;
if (YueFen = 10 YueFen = 4) {
if (XuanZe == 1) {
JiaGe = 5000 * 0.9;
System.out.println("机票的价格为:" + JiaGe);
} else if (XuanZe == 2) {
JiaGe = 5000 * 0.8;
System.out.println("机票的价格为:" + JiaGe);
} else {
System.out.println("输入错误");
}
} else if (YueFen = 1 YueFen = 3 || YueFen == 11 || YueFen == 12) {
if (XuanZe == 1) {
JiaGe = 5000 * 0.5;
System.out.println("机票的价格为:" + JiaGe);
} else if (XuanZe == 2) {
JiaGe = 5000 * 0.4;
System.out.println("机票的价格为:" + JiaGe);
} else {
System.out.println("输入错误");
}
}
}
}
java编程。订购机票,机票的价格受到季节旺季。淡季影响,而且头等藏跟经济舱的价格也不一同。
public class Ticket {
private int month;
private int classLevel; //1: 头等舱, 2: 经济舱
private int price;
private int basePrice = 5000; //原价
public Ticket(int month, int classLevel) {
this.month = month;
this.classLevel = classLevel;
}
public void showMeThePrice() {
//旺季月份: 4-10
if ((month = 4) (month = 10)) {
if (classLevel == 1) {
price = basePrice * 0.9;
System.out.println("Month: " + month + "; Class: " + classLevel + "; Price: " + price);
} else if (classLevel == 2) {
price = basePrice * 0.8;
System.out.println("Month: " + month + "; Class: " + classLevel + "; Price: " + price);
}
}
// 淡季月份: 1,2,3,11,12
if ((month = 1) (month = 3) || month = 11 || month = 12) {
if (classLevel == 1) {
price = basePrice * 0.5;
System.out.println("Month: " + month + "; Class: " + classLevel + "; Price: " + price);
} else if (classLevel == 2) {
price = basePrice * 0.4;
System.out.println("Month: " + month + "; Class: " + classLevel + "; Price: " + price);
}
}
}
}
测试类:
public class Test {
Ticket myTicket = new Ticket(4, 1); //例如:四月,头等舱
myTicket.showMeThePrice();//输出显示价格
...
}
以上代码全部手打,因为公司没有安装jdk,所以无法测试,你自己调试吧。
用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;
}
}
网站栏目:java机票打折代码 航空公司折扣代码
URL网址:http://pwwzsj.com/article/hhpeij.html