You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.2 KiB
110 lines
2.2 KiB
package Internship;
|
|
|
|
public class jjcc {
|
|
static void sum(double a, double b) {
|
|
double resum=a+b;
|
|
System.out.println(a+"+"+b+"="+resum);
|
|
}
|
|
static void subtraction(double a,double b) {
|
|
double resub=a-b;
|
|
System.out.println(a+"-"+b+"="+resub);
|
|
}
|
|
static void mul(double a,double b) {
|
|
double remul=a*b;
|
|
System.out.println(a+"*"+b+"="+remul);
|
|
}
|
|
static void division(double a,double b) {
|
|
double redivision=0;
|
|
if(b!=0) {
|
|
redivision=a/b;
|
|
}
|
|
else {
|
|
redivision=0; /*表示错误*/
|
|
}
|
|
System.out.println(a+"÷"+b+"="+redivision);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
package Internship;
|
|
|
|
public class ex {
|
|
static void e(int x) {
|
|
double e=Math.E;
|
|
double result;
|
|
|
|
result=Math.pow(e,x);
|
|
System.out.println("result="+result);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
package Internship;
|
|
|
|
|
|
public class logax {
|
|
static void log(int a, int x) {
|
|
System.out.println("log"+a+" "+x+" = "+(Math.log(x)/Math.log(a)));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
package Internship;
|
|
|
|
public class Trigonometric_Functions {
|
|
public Trigonometric_Functions(String chose,double Value) {
|
|
double a = Math.toRadians(Value);
|
|
switch(chose) {
|
|
case "sin":
|
|
System.out.println(String.format("%.2f",Math.sin(a)));
|
|
break;
|
|
case "cos":
|
|
System.out.println(String.format("%.2f",Math.cos(a)));
|
|
break;
|
|
case "tan":
|
|
System.out.println(String.format("%.2f",Math.tan(a)));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
package Internship;
|
|
|
|
import java.util.Scanner;
|
|
|
|
public class Test {
|
|
public static void main(String[] args) {
|
|
int a, b;
|
|
Scanner sc = new Scanner(System.in);
|
|
|
|
System.out.println("输入a的值:");
|
|
a = sc.nextInt();
|
|
System.out.println("输入b的值:");
|
|
b = sc.nextInt();
|
|
|
|
System.out.println("加减乘除运算:");
|
|
jjcc.sum(a, b);
|
|
jjcc.subtraction(a, b);
|
|
jjcc.mul(a, b);
|
|
jjcc.division(a, b);
|
|
System.out.println();
|
|
|
|
System.out.println("e的x次方运算:");
|
|
ex.e(a);
|
|
System.out.println();
|
|
|
|
System.out.println("logax运算:");
|
|
logax.log(a, b);
|
|
System.out.println();
|
|
|
|
System.out.println("三角函数运算:");
|
|
Trigonometric_Functions tf1 = new Trigonometric_Functions("sin", 30);
|
|
Trigonometric_Functions tf2 = new Trigonometric_Functions("cos", 30);
|
|
Trigonometric_Functions tf3 = new Trigonometric_Functions("tan", 30);
|
|
}
|
|
}
|