go to previous page   go to home page   go to next page

Answer:

x*x

x squared is x times x, of course. Don't use pow() for this. But if you need to compute x2.45 then use pow().


Interest

Money in a bank account earns interest. The value of the account depends on the principal, the interest rate, and the length of time. The formula for continuously compounded interest is:

A = Pert

where P is the principal (the initial amount), A is the currrent amount, r is the annual interest rate, and t is the number of years. Here is an interest calculator:

import java.util.* ;

public class ContinuousInterest
{
  public static void main (String[] args) 
  {
    Scanner scan = new Scanner( System.in );
    double rate, years, principal, amount;

    // read in the interest rate, as a fraction,
    // years and principal
    System.out.print  ("Enter rate:");
    rate = scan.nextDouble();  
    System.out.print  ("Enter years:");
    years = scan.nextDouble();  
    System.out.print  ("Enter principal:");
    principal = scan.nextDouble();  
    
    // calculate the amount after years of growth
    amount =   ;
    
    // write out the result
    System.out.println("current amount: " + amount );
  }
}

The rate should be entered as a fraction, like 0.06 for six percent annual rate.


QUESTION 24:

Fill in the bank.


go to previous page   go to home page   go to next page