Textbook Notes (368,528)
United States (206,055)
CMPSC 121 (11)
N/ A (7)
Chapter 4

Ch4_Problem_Set.rtf

5 Pages
159 Views
Unlock Document

Department
Computer Science
Course
CMPSC 121
Professor
N/ A
Semester
Fall

Description
IST 297DIntroduction to Application ProgrammingChapter 4 Problem SetName 1Write a Java program to compute the value of an investment over a number of years Prompt the user to enter the amount of the initial investment the rate of return and the number of years Use a while loop to control iterations Print both the year and the current value of the investment on each line 2 pointsimport javautilScannerpublic class WhileLoopInvestmentProblem param args the command line arguments public static void mainString argsConstructs an investment object from a starting balance and interest rate User starts off with 10000 at a rate of 5 return over 2 years final double INITIALBALANCE10000final double RATE5final double TARGET2INITIALBALANCEdouble balanceINITIALBALANCESystemoutprintEnter number of years Scanner innew ScannerSysteminint nyearsinnextIntwhile balanceTARGETnyearsdouble interestbalanceRATE100balancebalanceinterestSystemoutprintlnThe investment doubled after nyears years 2Repeat problem 1 this time using a for loop 2 pointsimport javautilScannerpublic class ForLoopInvestmentProblemJava
More Less

Related notes for CMPSC 121

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit