第四周作业

1.
package com.itheima08;
import java.util.Scanner;
public class HelloBudget {
public static void main(String[] args ){
Scanner input=new Scanner(System.in);
System.out.print("请输入x的取值:");
int x=input.nextInt();
if(x==1){System.out.println(x);
}
else if (x==5){System.out.println(x);
}
else if (x==10){System.out.println(x);
}else {System.out.println("none");
}
}
}



2.package com.itheima08;
import java.util.Scanner;
public class HelloBudget {
public static void main(String[] args ){
Scanner input=new Scanner(System.in);
System.out.print("请输入x的取值:");
int x=input.nextInt();
switch(x){
case 1:
    System.out.println("1");
break;
case 5:
    System.out.println("5");
    break;
case 10:
    System.out.println("10");
    break;
default:
    System.out.println("none");
    break;
}
}
 
     
}



3.package com.itheima08;
import java.util.Scanner;
public class HelloBudget {
public static void main(String[] args ){
     Scanner input =new Scanner(System.in);
      
     System.out.print(" please import a number:");
      
     int i = input.nextInt();
     if(i%5==0&&i%6==0){
         System.out.println(i+"能够被5和6同时整除");
     }else if(i%5==0&&i%6!=0){
         System.out.println(i+"只能够被5整除");
     }else if(i%6==0&&i%5!=0){
         System.out.println(i+"只能够被6整除");
     }else if(i%6!=0&&i%5!=0){
         System.out.println(i+"不能够被5和6整除");
     }
 
 }
}



4.package com.itheima08;
import java.util.Scanner;
public class HelloBudget {
public static void main(String[] args ){
Scanner input=new Scanner(System.in);
System.out.print("请输入一个0~100之间的整数:");
int x=input.nextInt();
String grade="";
if(x>=90&&x<=100){
    grade="A";
}
else if(x>=80&&x<=89){
    grade="B";
}
else if(x>=70&&x<=79){
    grade="C";
}
else if(x>=60&&x<=69){
    grade="D";
}
else if(x>=0&&x<=59){
    grade="E";
}
else {
    grade="false";
}
System.out.println(grade);
}



5.
package com.itheima08;
import java.util.Scanner;
public class HelloBudget {
public static void main(String[] args ){
Scanner input=new Scanner(System.in);
System.out.print("请输入第一个数:");
int a=input.nextInt();
System.out.println();
System.out.print("请输入第二个数:");
int b=input.nextInt();
System.out.println();   
System.out.print("请输入第三个数:");
int c=input.nextInt();
System.out.println();   
if(a>b&&b>c){
    System.out.println(c+"<"+b+"<"+a);
}
else if(a>c&&c>b){
    System.out.println(b+"<"+c+"<"+a);}
    else if(b>a&&a>c){
        System.out.println(c+"<"+a+"<"+b);    
    }
    else if(c>a&&a>b){
        System.out.println(b+"<"+a+"<"+c);        
}
    else if(b>c&&c>a){
        System.out.println(a+"<"+c+"<"+b);    
}
    else if(c>b&&b>a){
        System.out.println(a+"<"+b+"<"+c);    
}
 
}
}
 

1.编写程序, 输入变量x的值,如果是1,输出x=1,如果是5,输出x=5,如果是 10,输出 x=10,除了以上几个值,都输出x=none。(知识点:if条件语句)

2.用switch结构实现第1题

3.判断一个数字是否能被5和6同时整除(打印能被5和6整除),或只能被5整除(打印能被5整 除),或只能被6整除,(打印能被6整除),不能被5或6整除,(打印不能被5或6整除)

4.输入一个0~100的分数,如果不是0~100之间,打印分数无效,根据分数等级打印 A(90-100),B(80-89),C,D,E(知识点:条件语句if elseif)

5.输入三个整数x,y,z,请把这三个数由小到大输出(知识点:条件语句)

你可能感兴趣的:(第四周作业)