package methods; /** * * @author stephenwessels */ import java.util.Scanner; public class Methods { Scanner in = new Scanner(System.in); public int rad2deg() { int deg; int rads; deg = in.nextInt(); rads = in.nextInt(); return deg; } /** * @param args the command line arguments */ public static void main(String[] args) { Scanner in2 = new Scanner(System.in); System.out.println("This caluclator requires you to enter a function and a number.\n The functions are as follows:\n S - sine \n C - cosine \n T - tangent \n R - Square Root" + "\n N - natural log \n X 0 - Exit Program \n \n Please enter a function then a value."); String input = in2.nextLine().toUpperCase(); char operation = input.charAt(0); String sValue = input.substring(2); double dNum = Double.parseDouble(sValue); while(!"X 0".equals(input)) { switch(operation) { case 'S': double sine = Math.sin(dNum); System.out.println("The sine of your number is " + sine); System.out.println("The sine of your number in degrees is " + deg); break; case 'C': double cosine = Math.cos(dNum); System.out.println("The cosine of your number is " + cosine); System.out.println("The cosine of your number in degrees is " + deg); break; case 'T': double tangent = Math.tan(dNum); System.out.println("The tangent of your number is " + tangent); System.out.println("The tangent of your number in degrees is " + deg); break; case 'R': double Sq = Math.sqrt(dNum); System.out.println("The square root of your number is " + Sq); break; case 'N': double log = Math.log(dNum); System.out.println("The double log of your number is " + log); break; } input = in2.nextLine().toUpperCase(); } System.out.println("Thanks for using the calculator."); } }
static int deg
rad2deg
public class JavaApplication26 { static int deg; // declare it here Scanner in = new Scanner(System.in); .....
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)