Commit 1090fe1e authored by stephanie.smith's avatar stephanie.smith

initial

parents
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
import java.util.Scanner;
public class BankAccount {
static int accountNumber;
static String name;
static int balance;
static Scanner sc = new Scanner(System.in);
//constructors
public BankAccount(Integer accountNumber, String name, Integer balance){
this.accountNumber=accountNumber;
this.name=name;
this.balance=balance;
}
public static void main(String[] args){
BankAccount stephanie = new BankAccount(1111, "Stephanie",100);
Open(stephanie);
deposit(stephanie);
withdrawl(stephanie);
bankFees(stephanie);
accureInterest(stephanie);
addOverdraft(stephanie);
}
//standard account
//display account
public static void Open(BankAccount amount){
System.out.println("Account details");
System.out.println("Name: "+name);
System.out.println("Account number: "+accountNumber);
System.out.println("Balance: "+balance);
}
//deposit
public static void deposit(BankAccount amount){
int amt;
System.out.println("Deposit amount: ");
amt=sc.nextInt();
balance=balance+amt;
System.out.println("New balance: "+balance);
}
//withdrawl
public static void withdrawl(BankAccount amount){
int amt;
System.out.println("Withdrawl amount: ");
amt=sc.nextInt();
if(balance>=amt){
balance=balance-amt;
System.out.println("Balance after transaction: "+balance);
}
else{
System.out.println("insufficient funds. You have: "+balance);
}
}
//5% bank fees
public static void bankFees(BankAccount amount){
System.out.println("Bank fees");
System.out.println("Your current balance: "+balance);
balance=balance-((balance/100)*5);
System.out.println("Your balance after fees applied: "+balance);
}
//savings account
//adds 5% interest to balance
public static void accureInterest(BankAccount amount){
System.out.println("Savings account");
System.out.println("Your current balance: "+balance);
balance=balance+((balance/100)*5);
System.out.println("Your balance after interest added: "+balance);
}
//overdraft
public static void addOverdraft(BankAccount amount){
System.out.println("Overdraft limit");
int amt;
int limit = balance+100;
System.out.println("Balance: "+balance);
System.out.println("How much would you like to withdraw: ");
amt=sc.nextInt();
if(amt<=balance){
balance=balance-amt;
System.out.println("New balance: "+balance);
}else if(amt<=limit){
System.out.println("Overdraft application");
balance=balance-amt;
System.out.println("Your new balance is: "+balance);
}else{
System.out.println("Insufficient funds");
System.out.println("Your balance is: "+balance);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment