1、根据天数(从控制台上输入)计算周数和剩余的天数
import java.util.Scanner;
public class Work01{
public static void main(String [] args){
Scanner sc=new Scanner (System.in);
System.out.println(“请输入天数:”);
int Day=sc.nextInt();
int week;
week=Day/7;
int leftDay;
leftDay=Day%7;
System.out.println(“week=”+week);
System.out.println(“leftDay=”+leftDay);
}
}
2、根据已知圆的半径radius(从控制台上输入),求其面积和周长
import java.util.Scanner;
public class Work02{
public static void main(String [] args){
Scanner sc=new Scanner (System.in);
System.out.println(“请输入圆的半径:”);
int r=sc.nextInt();
double π=3.14;
int s=(int)((rr)π);
int c=(int)(2rπ);
System.out.println(“s=”+s);
System.out.println(“c=”+c);
}
}
3、控制台上输入两个数,求和、查、商、积、余
import java.util.Scanner;
public class Work03{
public static void main (String [] args){
Scanner sc=new Scanner(System.in);
System.out.println(“请输入第一个数:”);
int a=sc.nextInt();
System.out.println(“请输入第二个数:”);
int b=sc.nextInt();
System.out.println(a+"+"+b+"="+(a+b));
System.out.println(a+"-"+b+"="+(a-b));
System.out.println(a+""+b+"="+(ab));
System.out.println(a+"/"+b+"="+(a/b));
System.out.println(a+"%"+b+"="+(a%b));
}
}
4、输入成绩,判断学生的学习情况
100 满分/0 0分/1~59 不及格/60~70 及格/70~80 中/80~90 良好/90~100 秀
import java.util.Scanner;
public class Work04{
public static void main (String [] args){
Scanner sc=new Scanner(System.in);
System.out.println(“请输入你的成绩:”);
int score=sc.nextInt();
if(score0){
System.out.println(“你没来上过课吧!”);
}else if((score>0)&&(score<60)){
System.out.println(“你已经挂科,准备补考吧!”);
}else if((score>=60)&&(score<70)){
System.out.println(“饶你一命,飘过!”);
}else if((score>=70)&&(score<80)){
System.out.println(“你表现的还可以!”);
}else if((score>=80)&&(score<90)){
System.out.println(“成绩非常好,良好!”);
}else if((score>=90)&&(score<100)){
System.out.println(“你可真是个秀儿!”);
}else if(score100){
System.out.println(“你是我的小宝贝!”);
}else if((score>100)||(score<0)){
System.out.println(“你是火星来的逗比吗?”);
}
}
}
5、用户输入两个数a、b。如果a能被b整除或a加b大于1000,则输出a;否则输出b
import java.util.Scanner;
public class Work05{
public static void main(String [] args){
Scanner sc=new Scanner(System.in);
System.out.println(“请输入数字a:”);
int a=sc.nextInt();
System.out.println(“请输入数字b:”);
int b=sc.nextInt();
if ((b%a==0)||((a+b)>1000)){
System.out.println(a);
}else {
System.out.println(b);
}
}
}