home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BURKS 2
/
BURKS_AUG97.ISO
/
BURKS
/
LANGUAGE
/
JAVA
/
NOTES
/
SOURCE
/
intrest1.jav
< prev
next >
Wrap
Text File
|
1996-12-20
|
1KB
|
48 lines
/* Simulation of console-I/O program Interest2,
using ConsoleApplet as a basis. See the file
ConsoleApplet.java for more information.
David Eck
eck@hws.edu
August 2, 1996
*/
public class Interest1Console extends ConsoleApplet {
public void init() {
title = "Sample program \"Interest1\"";
super.init();
}
protected void program() {
/*
Program computes the amount of interest that is
earned on $17,000 invested at an interest
rate of 0.07 for one year. The interest and
the value of the investment after one year are
printed to standard output.
*/
double principal = 17000; // the value of the investment
double rate = 0.07; // the annual interest rate
double interest; // interest earned in one year
interest = principal * rate; // compute the interest
principal = principal + interest;
// compute value of investment after one year, with interest
// (Note: The new value replaces the old value of pricipal.)
console.put("The interest earned is $");
console.putln(interest);
console.put("The value of the investment after one year is $");
console.putln(principal);
}
}