demo1
public class MoveDesk {
public static void main(String[] args){
int age = 5;
char sex = '女';
if(age >= 7 || (age >= 5 && sex == '男')){
System.out.println("能搬动桌子");
}else{
System.out.println("不能搬动桌子");
}
}
}
demo2
import java.util.Scanner;
/*
*
*/
public class AddCust {
public static void main(String[] args) {
System.out.println("我行我素购物管理系统 > 客户信息管理 > 添加客户信息\n");
Scanner input = new Scanner(System.in);
int custNo = input.nextInt();
String custBirth = input.next();
System.out.print("请输入积分:");
int custScore = input.nextInt();
if(custNo >= 1000 && custNo <= 9999){
");
System.out.println(custNo + "\t" + custBirth + "\t" + custScore);
}else{
System.out.println("\n客户号" + custNo + !");
System.out.println("录入信息失败!");
}
}
}
demo4
import java.util.Scanner;
public class Discount {
/**
* @param args
*/
public static void main(String[] args)
{
int price = 4000; // 机票的原价
int month; // 出行的月份
int type; // 头等舱为1,经济舱为2
Scanner input = new Scanner(System.in);
System.out.println("请输入您出行的月份:1~12");
month = input.nextInt();
System.out.println("请问您选择头等舱还是经济舱?头等舱输入1,经济舱输入2");
type = input.nextInt();
if (month >= 5 && month <= 10) // 旺季
{
if (type == 1) // 头等舱
{
System.out.println("您的机票价格为:"+price * 0.9);
}
else if (type == 2) // 经济舱
{
System.out.println("您的机票价格为:"+ price * 0.75);
}
}
else // 淡季
{
if (type == 1) // 头等舱
{
System.out.println("您的机票价格为:"+ price * 0.6);
}
else if (type == 2) // 经济舱
{
System.out.println("您的机票价格为:"+ price * 0.3);
}
}
}
}
demo5
import java.util.Scanner;
public class Award {
public static void main(String[] args) {
System.out.print("考试成绩是: ");
Scanner input = new Scanner(System.in);
int score = input.nextInt(); // 考试成绩
if(score>100 || score<0){
System.out.println("必须在1--100之间");
}else{
switch (score / 10) {
case 10:
System.out.println("父亲给她买辆车");
break;
case 9:
System.out.println("母亲给她买台笔记本电脑");
break;
case 8:
case 7:
case 6:
System.out.println("母亲给她买部手机");
break;
default:
System.out.println("没有礼物");
}
}
}
}