1
2
3
4
5
6
7
8
9
10
package exercise;
import lib.Input;
public class Pass6_1 {
    public static void main(String[] args) {
        double a = Input.getDouble("角度");
        double b = Math.toRadians(a);
        System.out.printf("sin = %6.3f%n", Math.sin(b));
        System.out.printf("cos = %6.3f%n" ,Math.cos(b));
    }
}

1
2
3
4
5
6
7
8
9
10
11
package exercise;
import lib.Input;
public class Pass6_2 {
    public static void main(String[] args) {
        double a = Input.getDouble("a");
        double b = Input.getDouble("b");
        double c = Input.getDouble("c");
        double d = Math.abs(Math.pow(b, 2) - 4*a*c);
        System.out.printf("ans=%5.2f%n" ,Math.sqrt(d));
    }
}

1
2
3
4
5
6
7
8
package exercise;
public class Pass6_3 {
    public static void main(String[] args) {
        double a = Math.random();
        int p = (int)(6*a+1);
        System.out.println("サイコロの目数=" + p);
    }
}

1
2
3
4
5
6
7
8
9
10
11
12
package exercise;
import lib.Input;
public class Pass6_4 {
    public static void main(String[] args) {
        int a = Input.getInt("a");
        int b = Input.getInt("b");
        int c = Input.getInt("c");
         
        int max = Math.max(Math.max(a, b), c);
        System.out.println("a,b,cの中の最大値=" + max);
    }
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package exercise;
import lib.Input;
public class Pass6_5 {
    public static void main(String[] args) {
        String str1 = Input.getString("文字列");
        System.out.println("文字数=" + str1.length());
        System.out.println("先頭から5文字=" + str1.substring(05));
        System.out.println("先頭から7文字目=" + str1.charAt(6));
         
        String str2 = str1.replace("5","0");
        String str3 = str2.toUpperCase();
        System.out.println("str2=" + str2);
        System.out.println("str3=" + str3);
    }
}