上机作业。

1.

 
 
package asd;
import java.util.Scanner;
public class cc { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("请输入"); Scanner s = new Scanner(System.in); int x= s.nextInt(); if(x==1 || x==5 || x==10) { System.out.println("x="+x); }else { System.out.println("x=none"); } } }

2.
package asd;
 
import java.util.Scanner;
 
public class cc{
     public static void main(String[] args) {
         // TODO Auto-generated method stub
         Scanner input = new Scanner(System.in);
         
         System.out.print( "请输入一个数字:" );
         
         int i = input.nextInt();
         
         switch (i){
             case 1 :
                 System.out.println( "x=" +i);
                 break ;
             case 5 :
                 System.out.println( "x=" +i);
                 break ;
             case 10 :
                 System.out.println( "x=" +i);
                 break ;
             default :
                 System.out.println( "x=none" );
                 break ;
         }
 
     }
 
}
3.
package asd;
import java.util.Scanner;
public class cc { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("请输入"); Scanner s = new Scanner(System.in); int x= s.nextInt(); if(x%5==0&&x%6==0) { System.out.println("能被5和6整除"); }else if(x%5==0&&x%6!=0) { System.out.println("能被5整除"); }else if(x%6==0&&x%5!=0) { System.out.println("能被6整除"); }else if(x%5!=0&&x%6!=0) { System.out.println("不能被5或6整除"); } } }

4.
package asd;

import java.util.Scanner;

public class cc { public static void main(String[] args){ Scanner sc=new Scanner(System.in); System.out.println(" 输入分数:"); Scanner input = new Scanner(System.in); int x=input.nextInt(); if(x<0||x>100){ System.out.println("无效"); }else if(x>=90){ System.out.println("A"); }else if(x>=80){ System.out.println("B"); }else if(x>=70){ System.out.println("C"); }else if(x>=60){ System.out.println("D"); }else if(x<60){ System.out.println("E"); } } }


5.
package asd;
import java.util.Scanner;
public class cc { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("输入x的值"); int x=input.nextInt(); System.out.println("输入y的值"); int y=input.nextInt(); System.out.println("输入z的值"); int z=input.nextInt(); if(x>y&&y>z){ System.out.println("输出"+z+","+y+","+x); }else if(y>x&&x>z){ System.out.println("输出"+y+","+z+","+x); }else if(z>x&&x>y){ System.out.println("输出"+y+","+x+","+z); }else if(y>z&&z>x){ System.out.println("输出"+x+","+z+","+y); }else if(x>z&&z>y){ System.out.println("输出"+y+","+z+","+x); }else if(z>y&&y>x){ System.out.println("输出"+x+","+y+","+z); } } }




 

你可能感兴趣的:(上机作业。)