Math

Questions

  1. Use one line code to show the result of cos 75 deg
  2. Write a method int random(int max) generates a random integer from 1 to max.
  3. Write a method double interest(double amount, double interest_rate, int year) returns the interests.

Answer

  1. System.out.println(Math.cos(75));
  2. int random(int max) {
       return 1 + (int)(max*Math.random()); 
    }
    
  3. double interest(double amount, double interest_rate, int year) {
        return amount*Math.pow(1 + interest_rate, year) - amount;
    }