123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
-
- /**
- * Write a description of class Functions here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
-
- import java.util.Scanner;
- import java.lang.Math;
- import java.lang.Math;
- import java.math.BigDecimal;
-
- public class Functions
- {
-
- double first;
- double second;
- static double mem;
- static double value;
- public static int display;
- public static String show = "Decimal";
- static Scanner scan = new Scanner(System.in);
-
- public void functions() {
- }
-
- public static double add(double first, double second){
- double value = first + second;
- return value;
-
- }
- public static double subtract(double first, double second){
- double value = first - second;
- return value;
- }
-
- public static double multiply(double first, double second){
-
- double value = first * second;
- return value;
- }
-
- public static double divide(double top, double bot){
-
- if (bot != 0){
- return (top / bot);
- } else {
- System.out.println("ERROR! ERROR! Try using some numbers that work!");
- }
-
- return top / bot;
- }
-
- public static double square(double input){
- double value = Math.pow(input, 2);
- return value;
- }
-
- public static double squareRoot(double input){
-
- return Math.sqrt(input);
-
- }
- public static double exponent(double first, double exp){
-
- double value = Math.pow(first, exp);
- return value;
- }
-
- public static double inverse(double input){
-
- double value = 1/(input);
- return value;
- }
-
- public static double invertSign(double input){
- double value = -(input);
- return value;
- }
-
- public static String radDeg = scan.nextLine();
-
- public static double sin(double input){
-
- System.out.println("radians or degrees?");
- String radDeg = scan.nextLine();
- if(radDeg.equalsIgnoreCase("degrees")){
- input = Math.toRadians(input);
-
- }
- else if(radDeg.equalsIgnoreCase("radians")){
- input = input;
-
- }
- value = Math.sin(input);
- return value;
- }
-
- public static double cos(double input){
- System.out.println("radians or degrees?");
- String radDeg = scan.nextLine();
- if(radDeg.equalsIgnoreCase("degrees")){
- input = Math.toRadians(input);
-
- }
- else if(radDeg.equalsIgnoreCase("radians")){
- input = input;
-
- }
- value = Math.cos(input);
- return value;
-
- }
-
- public static double tan(double input){
- System.out.println("radians or degrees?");
- String radDeg = scan.nextLine();
- if(radDeg.equalsIgnoreCase("degrees")){
- input = Math.toRadians(input);
-
- }
- else if(!radDeg.equalsIgnoreCase("radians")){
- input = input;
-
- }
- value = Math.tan(input);
- return value;
- }
-
- public static double arcsin(double input){
- double answer = 0;
- System.out.println("radians or degrees?");
- String radDeg = scan.nextLine();
- if(radDeg.equalsIgnoreCase("degrees")){
-
- answer = (float)Math.toDegrees(Math.asin(input));
-
- }
- else if(radDeg.equalsIgnoreCase("radians")){
-
- answer = Math.asin(input);
-
- }
- value = answer;
- return value;
-
- }
-
- public static double arccos(double input){
- double answer = 0;
- System.out.println("radians or degrees?");
- String radDeg = scan.nextLine();
- if(radDeg.equalsIgnoreCase("degrees")){
-
- answer = Math.toDegrees(Math.acos(input));
-
- }
- else if(radDeg.equalsIgnoreCase("radians")){
-
- answer = Math.acos(input);
-
- }
- value = answer;
- return value;
-
- }
-
- public static double arctan(double input){
- double answer = 0;
- System.out.println("radians or degrees?");
- String radDeg = scan.nextLine();
- if(radDeg.equalsIgnoreCase("degrees")){
-
- answer = Math.toDegrees(Math.atan(input));
-
- }
- else if(radDeg.equalsIgnoreCase("radians")){
-
- answer = Math.atan(input);
-
- }
- value = answer;
- return value;
- }
-
- public static double csc(double input){
- System.out.println("radians or degrees?");
- String radDeg = scan.nextLine();
- if(radDeg.equalsIgnoreCase("degrees")){
- input = Math.toRadians(input);
-
- }
- else if(radDeg.equalsIgnoreCase("radians")){
- input = input;
-
- }
- value = 1/(Math.sin(input));
- return value;
-
- }
-
- public static double sec(double input){
- System.out.println("radians or degrees?");
- String radDeg = scan.nextLine();
- if(radDeg.equalsIgnoreCase("degrees")){
- input = Math.toRadians(input);
-
- }
- else if(radDeg.equalsIgnoreCase("radians")){
- input = input;
-
- }
-
- value = 1/(Math.cos(input));
- return value;
-
- }
-
- public static double cot(double input){
- System.out.println("radians or degrees?");
- String radDeg = scan.nextLine();
- if(radDeg.equalsIgnoreCase("degrees")){
- input = Math.toRadians(input);
-
- }
- else if(radDeg.equalsIgnoreCase("radians")){
- input = input;
-
- }
- value = 1/(Math.tan(input));
- return value;
- }
-
- public static double ln(double input){
- return Math.log(input);
-
- }
-
- public static double inverseLn(double input){
-
- return Math.exp(Math.log(input));
-
- }
-
- public static double memPlus(double value) {
- mem += value;
- return mem;
- }
-
- public static double memClear(double value) {
- mem = 0;
- return mem;
- }
-
- public static double recall() {
- return mem;
- }
-
-
-
-
- }
|