Console.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import java.util.Scanner;
  2. /**
  3. * Created by leon on 2/9/18.
  4. */
  5. public class Console {
  6. public static void print(String output, Object... args) {
  7. System.out.printf(output, args);
  8. }
  9. public static void println(String output, Object... args) {
  10. print(output + "\n", args);
  11. }
  12. /*
  13. public static String getStringInput(String prompt) {
  14. Scanner scanner = new Scanner(System.in);
  15. println(prompt);
  16. String userInput = scanner.nextLine();
  17. return userInput;
  18. }
  19. */
  20. public static int add(int num1,int num2){
  21. return num1 + num2;
  22. }
  23. public static int minus(int num1,int num2){
  24. return num1 - num2;
  25. }
  26. public static int mult(int num1,int num2){
  27. return num1 * num2;
  28. }
  29. public static int pow(double num1,double num2){
  30. double r = Math.pow(num1,num2);
  31. return (int)Math.round(r);
  32. }
  33. public static double squ(int num1){
  34. return (double) Math.sqrt(num1);
  35. }
  36. public static int min(int num1, int num2){
  37. return Math.min(num1,num2);
  38. }
  39. public static int max(int num1, int num2){
  40. return Math.max(num1,num2);
  41. }
  42. public static double exp (double num1){
  43. return Math.pow(2.718,num1);
  44. }
  45. public static double tenthpow(double num1){
  46. return Math.pow(10,num1);
  47. }
  48. public static int abs(int num1){
  49. return Math.abs(num1);
  50. }
  51. public static double round(double num1){
  52. return Math.round(num1);
  53. }
  54. public static long exp (int num1, int num2){
  55. int neg = -2147483647;
  56. int pos = 2147483647;
  57. long t = 0;
  58. if(num1 >= -1 || num1 <= neg){
  59. double re = Math.pow(num1,num2);
  60. return (long)re;
  61. }
  62. else if(num2 >= 1 || num2 <= pos ){
  63. double re2 = Math.pow(num2,num1);
  64. return (long)re2;
  65. }
  66. return t;
  67. }
  68. }