一周总结(6)()-其他
一周总结(6)()
//卖飞机票
package com.itheima.test;
public static void main (String [] args){
Scanner sc = new Scanner (System.in);
System.out.println(“请输入机票的原价”);
int ticket = sc.nwxtInt();
System.out.println(“请输入当前的月份”);
int month = sc.nextInt();
System.out.println(“请输入当前购买的舱位 0 头等舱 1 经济舱”);
int seat = sc.nwxtInt();
if(month>=5&&month<=10){
if(seat==0){
ticket=(int)(ticket*0.9);
}else if(seat==1){
ticket=(int)(ticket*0.85);
}else{
Syatem.out.printf(”没有这个舱位”);
}
}else if((month>=1&&month<=4)||(month>=11&&month<=12)){
if(seat==0){
ticket=(int)(ticket*0.7);
}else if(seat==1){
ticket=(int)(ticket*0.65);
}else{
Syatem.out.printf(”没有这个舱位”);
}else{
System.out.printf(“键盘录入的月份不合法”);
}
System.out.printf(ticket);
}
//找质数
//判断101~200之间有多少个质数,并打印所有质数
package com.itheima.test;
public class Test2 {
public static void main(string[] args) {
int count = 0;
for(int i=101;i<=200;i++){
boolean flag = true;
for(int j=2;j<i;j++){
1f(i %j == 0){
flag = false;
break;
}
}
if(flag){
system. out.println(“当前数字”+i+”是质数”);
}
}
//卖飞机票
package com.itheima.test;
public static void main (String [] args){
Scanner sc = new Scanner (System.in);
System.out.println(“请输入机票的原价”);
int ticket = sc.nwxtInt();
System.out.println(“请输入当前的月份”);
int month = sc.nextInt();
System.out.println(“请输入当前购买的舱位 0 头等舱 1 经济舱”);
int seat = sc.nwxtInt();
if(month>=5&&month<=10){
if(seat==0){
ticket=(int)(ticket*0.9);
}else if(seat==1){
ticket=(int)(ticket*0.85);
}else{
Syatem.out.printf(”没有这个舱位”);
}
}else if((month>=1&&month<=4)||(month>=11&&month<=12)){
if(seat==0){
ticket=(int)(ticket*0.7);
}else if(seat==1){
ticket=(int)(ticket*0.65);
}else{
Syatem.out.printf(”没有这个舱位”);
}else{
System.out.printf(“键盘录入的月份不合法”);
}
System.out.printf(ticket);
}
//找质数
//判断101~200之间有多少个质数,并打印所有质数
package com.itheima.test;
public class Test2 {
public static void main(string[] args) {
int count = 0;
for(int i=101;i<=200;i++){
boolean flag = true;
for(int j=2;j<i;j++){
1f(i %j == 0){
flag = false;
break;
}
}
if(flag){
system. out.println(“当前数字”+i+”是质数”);
}
}