- Create a class called Bank.
- Have main method in it. public static void main(String[] args)
- Create an object called 'bank'. Bank bank = new Bank()
- Using 'bank' object, call deposit(1000) bank.deposit(1000);
- Create a method deposit(int amount)
- return 1000 - 500 from this method.
- Store the returned value as amount.
- Print the amount
package terminaltask;
public class Bank {
public static void main(String[] args)
{
// TODO Auto-generated method stub
Bank indian = new Bank();
int amount = indian.deposit(1000);
System.out.println(amount);
}
public int deposit (int amount)
{
return 1000-500;
}
out put -- 500
}
Top comments (0)