1- Modify class Account to provide a method called debit that withdraws money from an Account.Ensure that the debit amount does not exceed the Account’s balance. If it does, the balance should be left unchangedand the method should print a message indicating "Debit amount exceeded account balance." Modifyclass AccountTest to test method debit.

Sample Output

Program Template

// Lab 1: Account.java

// Account class with a constructor to

// initialize instance variable balance.

public class Account

{

private double balance; // instance variable that stores the balance

// constructor

publicAccount( double initialBalance )

{

// validate that initialBalance is greater than 0.0;

// if it is not, balance is initialized to the default value 0.0

if( initialBalance0.0 )

balance = initialBalance;

} // end Account constructor

// credit (add) an amount to the account

public void credit( double amount )

{

balance = balance + amount; // add amount to balance

} // end method credit

// return the account balance

public double getBalance()

{

returnbalance; // gives the value of balance to the calling method

} // end method getBalance

} // end class Account

// Lab 1: AccountTest.java

// Create and manipulate an Account object.

importjava.util.Scanner;

public class AccountTest

{

// main method begins execution of Java application

public static void main( String args[] )

{

Account account1 = new Account(50.00 ); // create Account object

Account account2 = new Account(-7.53 ); // create Account object

// display initial balance of each object

System.out.printf("account1 balance: $%.2f\n", account1.getBalance() );

System.out.printf("account2 balance: $%.2f\n\n", account2.getBalance() );

// create Scanner to obtain input from command window

Scanner input = new Scanner( System.in );

doublewithdrawalAmount; // withdrawal amount read from user

System.out.print("Enter withdrawal amount for account1: " );

withdrawalAmount = input.nextDouble(); // obtain user input

System.out.printf("\nsubtracting %.2f from account1 balance\n", withdrawalAmount );

// display balances

System.out.printf("account1 balance: $%.2f\n", account1.getBalance() );

System.out.printf("account2 balance: $%.2f\n\n", account2.getBalance() );

System.out.print("Enter withdrawal amount for account2: " );

withdrawalAmount = input.nextDouble(); // obtain user input

System.out.printf("\nsubtracting %.2f from account2 balance\n", withdrawalAmount );

// display balances

System.out.printf("account1 balance: $%.2f\n", account1.getBalance() );

System.out.printf("account2 balance: $%.2f\n", account2.getBalance() );

} // end main

} // end class AccountTest

2 -For each of the following problems, write a program or a program segment that performs the specified action.

a)Write an empty class declaration for a class named Student.

b)Declare five instance variables in the class from Coding Exercise (a): A String variable for the first name, aString variable for the last name and three double variables that are used to store a student’s exam grades.

c) In the class from Coding Exercise (b), declare a constructor that takes five parameters—two StringS and threedoubles. Use these parameters to initialize the instance variables declared earlier.

d)4. Modify the class from Coding Exercise (c) to include a get and a set method for each of the instance variablesin the class.

e)Modify the class from Coding Exercise (d)to include a getAveragemethod that calculates and returns the averageof the three exam grades.

f)Declare an empty test class to use the capabilities of your new Student class from Coding Exercise (e).

g)In the class from Coding Exercise (f), declare a main method that creates an instance of class

h) Add statements to the main method of Coding Exercise (g)to test class Student’s get methods. Output thename and average for the student.\

i)Add statements to the main method of Coding Exercise (h)that test the set methods of class Student, then outputthe new name and average of the Student object to show that the set methods worked correctly.

EE 202 lab (#3)/ 1