Compare commits
No commits in common. 'qin' and 'master' have entirely different histories.
@ -0,0 +1,26 @@
|
||||
import java.util.Scanner;
|
||||
public class CALC{
|
||||
public static void main(String args[]){
|
||||
double x;
|
||||
double y;
|
||||
String z;
|
||||
Scanner sc=new Scanner(System.in)
|
||||
System.out.println("输入第一个数:");
|
||||
x=sc.nextDouble();
|
||||
System.out.println("输入运算符:");
|
||||
z=sc.next();
|
||||
System.out.println("输入第二个数:");
|
||||
y=sc.nextDouble();
|
||||
System.out.print("结果是:");
|
||||
switch(z){
|
||||
case"+":System.out.println(x+y);
|
||||
break;
|
||||
case"-":System.out.println(x-y);
|
||||
break;
|
||||
case"*":System.out.println(x*y);
|
||||
break;
|
||||
case"/":System.out.println(x/y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ¼Ó¼õ³Ë³ý;
|
||||
import java.util.*;
|
||||
public class d {
|
||||
String s;
|
||||
double x;
|
||||
public d(String s,double x)
|
||||
{
|
||||
this.s=s;
|
||||
this.x=x;
|
||||
}
|
||||
public double sanjiao()
|
||||
{
|
||||
if (s.equals("sin")) return sin(x);
|
||||
else if (s.equals("cos")) return cos(x);
|
||||
else if (s.equals("tan")) return tan(x);
|
||||
else if (s.equals("asin")) return asin(x);
|
||||
else if (s.equals("acos")) return acos(x);
|
||||
else if (s.equals("atan")) return atan(x);
|
||||
else return Double.POSITIVE_INFINITY;
|
||||
}
|
||||
private double sin(double x) {return Math.sin(x);}
|
||||
private double cos(double x) {return Math.cos(x);}
|
||||
private double tan(double x) {return Math.tan(x);}
|
||||
private double asin(double x) {return Math.asin(x);}
|
||||
private double acos(double x) {return Math.acos(x);}
|
||||
private double atan(double x) {return Math.atan(x);}
|
||||
}
|
Loading…
Reference in new issue