PPT Slide
Question 4 (20 points). Consider the ATM class below. It defines the specifications for an Automated Teller Machine object for one persons ATM account.
// An Automated Teller Machine class.
public int balance; // balance remaining in the account in whole dollars
// Prints the balance to the output window.
public void printBalance ( ) {
System.out.println (Balance is: + balance);
// Adds amount_to_deposit to the balance.
public void deposit (int amount_to_deposit ){
balance = balance + amount_to_deposit;
Fill out the body of the main method below so that it performs the following steps in order: (1) create an instance of an Atm object called my_atm; (2) initialize the balance to $1000 and print it to the output window using the printBalance method; (3) deposit $50 to the account using method deposit and print the new balance to the output window, again using the printBalance method. For full credit, your code should include proper comments and indentation.
public static void main ( String args [ ] ) {
Question 5 (20 points). Show the output of the following code.
public class Question {
public static void main ( String args [ ] ) {
C c1 = new C ();
C c2 = new C ();
System.out.println ( c1.x + + c1.y );
System.out.println ( c2.x + + c2.y );
c1.x = 5;
c1.y = 10;
c2.x = c1.y;
c2.y = c1.x;
System.out.println ( c1.x + + c1.y );
System.out.println ( c2.x + + c2.y );
c2 = c1;
System.out.println ( c1.x + + c1.y );
System.out.println ( c2.x + + c2.y );
c1.x = 7;
c2.y = 8;
System.out.println ( c1.x + + c1.y );
System.out.println ( c2.x + + c2.y );
}