java程序设计(第二次作业)

13:计算书费

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		int n = a.nextInt();
		double [] danjia = {28.9, 32.7, 45.6, 78, 35, 86.2, 27.8, 43, 56, 65};                                                                                                                                                                                                                                                                                                                                                               
		double [] benshu = new double[10];
		for (int m=0;m

14:整数的个数​​​​​

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		int n = a.nextInt();
		int sum1=0;
		int sum5=0;
		int sum10=0;
		for (int m=0;m

15:整数的立方和

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		int n = a.nextInt();
		int sum = 0;
		for (int s = 1;s<=n;s++) {
			sum=sum+s*s*s;
		}
		System.out.println(sum);
	}
}

16:化验诊断

import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		final int n = cin.nextInt();
		for (int i = 0; i < n; i++) {
			String gender = cin.next();
			double wbc = cin.nextDouble();
			double rbc = cin.nextDouble();
			int hgb = cin.nextInt();
			int hct = cin.nextInt();
			int plt = cin.nextInt();
			int count = 0;
			if (wbc < 4.0 || wbc > 10.0) {
				count++;
			}
			if (rbc < 3.5 || rbc > 5.5) {
				count++;
			}
			if ("male".equals(gender)) {
				if (hgb < 120 || hgb > 160) {
					count++;
				}
				if (hct < 42 || hct > 48) {
					count++;
				}
			} else if ("female".equals(gender)) {
				if (hgb < 110 || hgb > 150) {
					count++;
				}
				if (hct < 36 || hct > 40) {
					count++;
				}
			}
			if (plt < 100 || plt > 300) {
				count++;
			}
			if (count == 0) {
				System.out.println("normal");
			} else {
				System.out.println(count);
 
			}
		}
		cin.close();
	}
}

17:求分数序列和

import java.util.Scanner;
public class Main {
	 public static void main(String[] args) {
	    	Scanner cin = new Scanner(System.in);
			int n = cin.nextInt();
			double sum=0;
			double a=2;
			double b=1;
			double c;
			for(int i=1;i<=n;i++){
	            sum = sum+ a/b;
	            c = a;
	            a = a+b;
	            b = c;
	        }
			System.out.printf("%.4f\n",sum);
	}
}

18:求阶乘的和

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int sum2 = 0;
        for (int i=1;i<=n;i++) {
        	int sum1 = 1;
        	for(int j=1;j<=i;j++) {
        		sum1=sum1*j;
        	}
        	sum2=sum2+sum1;
        }
        System.out.println(sum2);    
     }
}        

19:打印完数

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        for (int i=1;i<=1000;i++) {
        	int sum=0;
        	String result;
        	List list = new ArrayList();
        	int summ = 0;
        	for (int j=1;j

20:数组逆序重放

import java.util.Scanner;
public class Main {
	 public static void main(String[] args) {
	    	Scanner cin = new Scanner(System.in);
			int n = cin.nextInt();
			int [] shuzu = new int [n];
			int [] shuzu2 = new int [n];
			for (int i=0;i=0;j--) {
				System.out. printf("%d ",shuzu[j]);	
			}
				
			
			
			
	}
}
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner a = new Scanner(System.in);
		int n = a.nextInt();
		int sum = 0;
		for (int i = 1;i<=n;i++) {
			
			if (i%7!=0 && i%10!=7 && i/10!=7) {
				sum=sum+i*i;
			}
		}
		System.out.println(sum);
    	
    	
    	
    	
    	
    }
}

22:骑车与走路

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner a = new Scanner(System.in);
		int n = a.nextInt();
		double qiche;
		double buxing;
		for (int i=0;ibuxing) {
				System.out.println("Walk");
				
			}else if(buxing>qiche) {
				System.out.println("Bike");
			}else {
				System.out.println("All");
			}
			
		}
    }
}

你可能感兴趣的:(Java作业,java)