Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2. Save it as MyFirstProgram.java
3. Open a Command Prompt
4. Change to the directory to where youve saved the above file (refer to
T2_slides.ppt for how to change directories)
5. Type in javac HelloWorld.java, followed by Enter
6. Type in java HelloWorld, followed by Enter
CityU IS Dept
1 | Page
2. Sales
3. Account Balance
A program that calculates the current balance in a savings account
must ask the user for the following:
The starting balance
The total dollar amount of deposits made
The total dollar amount of withdrawals made
The monthly interest rate
Once the program calculates the current balance, it should be
displayed on the screen.
Display "What is the account's starting balance?"
Input startingBalance.
Display "What is the total amount of the deposits made?"
Input deposits.
Display "What is the total amount of the withdrawals made?"
Input withdrawals.
Display "What is the monthly interest rate?"
Input interestRate.
balance = startingBalance + deposits withdrawals.
interest = balance * interestRate.
balance = balance + interest.
Display balance.
Exercise 5: --- Submit your work [Individual]
Please submit the answers (in MS Word format) of Exercise 3 and 4.3 to Canvas
under Tutorial WK2 Submission Link. (Deadline: 11/09/2016, 23:59, no late
submission will be accepted)
End of Tutorial 2
CityU IS Dept
3 | Page