Home > Java > javaTutorial > Bank task

Bank task

Patricia Arquette
Release: 2024-12-31 16:11:10
Original
716 people have browsed it

Bank task

  1. Create a class called Bank.
  2. Have main method in it. public static void main(String[] args)
  3. Create an object called 'bank'. Bank bank = new Bank()
  4. Using 'bank' object, call deposit(1000) bank.deposit(1000);
  5. Create a method deposit(int amount)
  6. return 1000 - 500 from this method.
  7. Store the returned value as amount.
  8. 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
}

The above is the detailed content of Bank task. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template