import java.util.Scanner;
public class day_01{
public static void main(String[] args){
test1();
test2();
test3();
test4();
test5();
test6();
test7();
test8();
}
public static void test1(){
char ch='a';
System.out.println(ch);
System.out.println(ch+1);
System.out.println(ch+2);
System.out.println((char)(ch+1));
System.out.println((char)(ch+2));
System.out.println((int)3.14);
}
public static void test2(){
int num1=3;
int num2=5;
int result=num1+num2;
System.out.println(result);
System.out.println(8/2);
System.out.println(8%2);
System.out.println(8/3);
System.out.println(8%3);
System.out.println(2/7);
System.out.println(2%7);
}
public static void test3(){
int i=3;
i++;
System.out.println(i);
System.out.println(i++);
System.out.println(++i);
System.out.println(3>=5);
System.out.println(5<=10);
}
public static void test4(){
int num3=3;
int num4=5;
System.out.println(num3<0 && num3++<num4);
System.out.println(num3);
System.out.println(num4);
System.out.println(num3>0||num3++<num4);
System.out.println(num3);
}
public static void test5(){
Scanner scanner=new Scanner(System.in);
System.out.println("请输入学生成绩:");
int score=scanner.nextInt();
if(score<0||score>100){
System.out.println("输入成绩非法!");
return;
}
if(score>=90&&score<100){
System.out.println("优秀");
}else if(score>=80&&score<90){
System.out.println("良好");
}else if(score>=70&&score<80){
System.out.println("一般");
}else if(score>=60&&score<70){
System.out.println("及格");
}else{
System.out.println("不及格");
}
}
public static void test6(){
Scanner scanner=new Scanner(System.in);
System.out.println("请输入年份:");
int year=scanner.nextInt();
if((year%4==0&&year%100!=0)||(year%400==0)){
System.out.println(year+"是闰年");
}else{
System.out.println(year+"是平年");
}
}
public static void test7(){
Scanner scanner=new Scanner(System.in);
System.out.println("请输入第一个数:");
int num5=scanner.nextInt();
System.out.println("请输入第二个数:");
int num6=scanner.nextInt();
System.out.println(num5);
System.out.println(num6);
int temp=num5;
num5=num6;
num6=temp;
System.out.println(num5);
System.out.println(num6);
}
public static void test8(){
Scanner scanner=new Scanner(System.in);
System.out.println("请输入单价:");
double danjia=scanner.nextDouble();
System.out.println("请输入数量:");
double count=scanner.nextInt();
System.out.println("请输入用户金额:");
double price=scanner.nextDouble();
double totalPrice=danjia*count;
if (totalPrice>=500){
totalPrice=totalPrice*0.8;
}
double zhaoling=price-totalPrice;
if (zhaoling>0){
System.out.println("应收金额:"+totalPrice);
System.out.println("找零:"+zhaoling);
}else{
System.out.println("付款金额不足!");
}
}
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-1965.html