Commit fdd2fef4 authored by sam.drinkwater's avatar sam.drinkwater

master

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).
public class BankAccount{
int accountNumber;
String name;
int balance;
BankAccount(int accountNumber, String name, int balance){
this.accountNumber = accountNumber;
this.name = name;
this.balance = balance;
}
void deposit(double DepositAmount){
balance += DepositAmount;
}
void withdrawal(double WithdrawAmount){
if (balance >= WithdrawAmount){
balance -= WithdrawAmount;
}
else if (balance < WithdrawAmount){
System.out.println("\nNot enough funds");
}
}
void bankFees(){
balance *= 0.95;
}
void display(){
System.out.println("\nAccount Number: " + accountNumber);
System.out.println("Account name: " + name);
System.out.println("Account balance: " + "$"+balance);
}
public static void main(String args[])
{
BankAccount obj1 = new BankAccount(4321, "Philip", 3000);
obj1.deposit(0);
obj1.withdrawal(4000);
obj1.bankFees();
obj1.display();
}
}
\ No newline at end of file
public class Overdraft{
int accountNumber;
String name;
int balance;
int overdraftLimit;
Overdraft(int accountNumber, String name, int balance, int overdraftLimit){
this.accountNumber = accountNumber;
this.name = name;
this.balance = balance;
this.overdraftLimit = overdraftLimit;
}
void deposit(double DepositAmount){
balance += DepositAmount;
}
void withdrawal(double WithdrawAmount){
if (balance >= WithdrawAmount){
balance -= WithdrawAmount;
}
else if (balance < WithdrawAmount){
System.out.println("\nI'm sorry. You don't have enough funds to complete this transaction.");
System.out.println("----------------------------------------------------------------------");
}
}
void bankFees(){
balance *= 0.95;
}
void addOverdraft(int OverdraftTaken){
if (overdraftLimit >= OverdraftTaken){
balance += OverdraftTaken;
}
else{
System.out.println("\nI'm sorry, you've exceded your overdraft limit.");
System.out.println("----------------------------------------------------------------------");
}
}
void display(){
System.out.println("\nAccount Number: " + accountNumber);
System.out.println("Account name: " + name);
System.out.println("Account balance: " + "$"+balance);
}
public static void main(String args[])
{
Overdraft obj1 = new Overdraft(432173432, "Philip J Lahm", 3000, 1000);
obj1.deposit(0);
obj1.withdrawal(9000);
obj1.bankFees();
obj1.addOverdraft(800);
obj1.display();
}
}
\ No newline at end of file
public class SavingsAccount{
int accountNumber;
String name;
int balance;
SavingsAccount(int accountNumber, String name, int balance){
this.accountNumber = accountNumber;
this.name = name;
this.balance = balance;
}
void deposit(double DepositAmount){
balance += DepositAmount;
}
void withdrawal(double WithdrawAmount){
if (WithdrawAmount <= 100){
if (balance >= WithdrawAmount){
balance -= WithdrawAmount;
}
else if (balance < WithdrawAmount){
System.out.println("\nNot enough funds");
}
}else{
System.out.println("\nWithdrawal limit of $100");
}
}
void accrueInterest(){
balance *= 1.05;
}
void addOverdraft(){
}
void display(){
System.out.println("\nAccount Number: " + accountNumber);
System.out.println("Account name: " + name);
System.out.println("Account balance: " + "$"+balance);
}
public static void main(String args[])
{
SavingsAccount obj1 = new SavingsAccount(4321, "Philip", 3000);
obj1.deposit(0);
obj1.withdrawal(100);
obj1.accrueInterest();
obj1.display();
}
}
\ 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