Compare commits

...

No commits in common. 'master' and 'qin' have entirely different histories.
master ... qin

@ -1,155 +0,0 @@
package test;
import java.util.Arrays;
import java.util.Scanner;
import java.util.*;
class power{
public static int factorial(int n){
int factorial=1;
int counter=1;
while (counter<1+n){
factorial*=counter+1;
counter++;
}
return factorial;
}
public static double ex(int n,int x){
double ex=1.0;
int counter=1;
while (counter<=n){
ex+=(double)Math.pow(x,counter)/factorial(counter);
counter++;
}
return ex;
}
}
class b {
public static void main(String[] args) {
int a;
int x;
double result;
System.out.println("输入底数a(a>0且a=1):");
Scanner sc = new Scanner(System.in);
a=sc.nextInt();
System.out.println("输入真数x:");
x=sc.nextInt();
result = log(x, a);
System.out.println(result);
}
public static double log(double value, double base) {
return Math.log10(value) / Math.log10(base);
}
}
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;
}
}
}
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);}
}
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
System.out.println("1 for e^x\n2 for logax\n3 for +-*/\n4 for 三角函数");
int calnum=s.nextInt();//选择数字决定进行哪种运算
if(calnum ==1){
System.out.println("type x:");
Scanner x=new Scanner(System.in);
System.out.println("result:"+power.ex(1, x.nextInt()));
}
if(calnum==2) {
int a,x;
System.out.println("type a:");
Scanner sc=new Scanner(System.in);
a=sc.nextInt();
System.out.println("type x:");
x=sc.nextInt();
System.out.println("result:"+b.log(x,a));
}
if(calnum==3) {
double x;
double y;
String z;
Scanner sc=new Scanner(System.in);
System.out.println("type the first number");
x=sc.nextDouble();
System.out.println("type calculation symbol");
z=sc.next();
System.out.println("type the second number");
y=sc.nextDouble();
System.out.print("result");
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;
}
}
if(calnum==4) {
System.out.println("choose sin,cos,tan,asin,acos or atan");
String ss;double x;
Scanner sc=new Scanner(System.in);
ss=sc.nextLine();
System.out.print("type x:");
x=sc.nextDouble();
d ch=new d(ss,x);
System.out.print("result"+ch.sanjiao());
}
}
}

@ -1,25 +0,0 @@
package eµÄx´Î·½;
public class power{
public static int factorial(int n){
int factorial=1;
int counter=1;
while (counter<1+n){
factorial*=counter+1;
counter++;
}
return factorial;
}
public static double ex(int n,int x){
double ex=1.0;
int counter=1;
while (counter<=n){
ex+=(double)Math.pow(x,counter)/factorial(counter);
counter++;
}
return ex;
}
}

@ -1,26 +0,0 @@
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;
}
}
}

@ -1,27 +0,0 @@
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…
Cancel
Save