Lab 4: Java programming with conditional statements
Assigned: Tuesday, September 25
Due: Tuesday, October 2
- Learn how to write a simple Java program with conditional statements
- Learn how to design and coding simple algorithms to solve the program
Be creative, and try to provide a nice user interface.
- Problem 1: Bank ATM Simulation. Write a Java program to simulate a transaction on a bank ATM machine. Assume the password and the initial balance of the account are fixed in the program (defined as constant). Your program should at least be able to
- verify the password entered by the user
- support three types of transactions: check the balance, deposit and withdraw money.
- prevent the user to withdraw more money that the account has.
- output the balance of the account after the operations of deposit or withdraw.
- Problem 2: Leap Year. Write a Java program that reads an integer value representing a year from the user, and output if it is a leap year. The following rules are used to decide which years are leap years:
- Every year divisible by 4 is a leap year.
- But every year divisible by 100 is NOT a leap year.
- Unless the year is also divisible by 400, then it is still a leap year.
- Sumbit the source code and output of both programs. Add the output as the comment into the program, and then print the programs using command a2ps as you did in the last lab.
- Make sure each program has
- header comments with assignment number, your name and your section;
- nice inline comments to explain your programs
- correctly indented code, no wrapped lines
- use symbolic constants instead of numeric constants.
- correct and nice output
- Please finish problem 1 first, and then problem 2. If you only finish problem 1, your highest grade will be B. If you finish both problems, your highest grade will be A.
Link to this Page