Commit 398b66fa authored by Daniel Pearson's avatar Daniel Pearson

Origin

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).
File added
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello, World!");
}
}
import java.util.Scanner;
public class BankAccount {
int accountNumber;
String name;
float balance;
static Scanner myObj = new Scanner(System.in);
//make it so it checks if the money is available in the account
public BankAccount(int accountNumber, String name, float balance){
this.accountNumber = accountNumber;
this.name = name;
this.balance = balance;
}
public static void main(String[] args){
BankAccount dan = new BankAccount(10192,"dan",1000);
deposit(dan);
withdrawal(dan);
bankFees(dan);
display(dan);
addOverdraft(dan);
}
public static void deposit(BankAccount amount){
System.out.println("\n"+"\n"+"How much would you like to deposit? ");
float depositAmount;
depositAmount = myObj.nextFloat();
amount.balance += depositAmount;
System.out.println("Your total bank balance is: "+"£"+amount.balance);
}
public static void withdrawal(BankAccount amount){
System.out.println("\n"+"\n"+"How much would you like to withdraw? ");
float withdrawAmount;
withdrawAmount = myObj.nextFloat();
if(withdrawAmount < amount.balance) {
amount.balance -= withdrawAmount;
System.out.println("Your account balance is now: "+"£"+amount.balance);
}else{
System.out.println("Sorry you do not have enough in your account. Your account balance is " + "£"+amount.balance);
}
}
public static void bankFees(BankAccount amount){
amount.balance -= amount.balance * 0.05;
System.out.println("\n"+"\n"+"Your balance after bank fees is: " + amount.balance);
}
public static void display(BankAccount amount){
System.out.println("\n"+"\n"+"Account Name: "+ amount.name + "\n" + "Account Number: "+amount.accountNumber + "\n" + "Current Balance: " +"£"+ amount.balance);
}
public static void addOverdraft(BankAccount amount){
if(amount.balance <= 0){
amount.balance += 500.0;
System.out.println("\n"+"\n"+"You Are Now In Your Overdraft");
}
}
}
class savingsAccount extends BankAccount{
public savingsAccount(int accountNumber, String Name, float balance){
super(accountNumber,Name,balance);
}
public static void main(String[] args){
BankAccount dan = new BankAccount(10192,"dan",1000);
savingsDeposit(dan);
savingsWithdrawal(dan);
savingsBankFees(dan);
savingsDisplay(dan);
Scanner myObj1 = new Scanner(System.in);
}
public static void savingsDeposit(BankAccount amount){
System.out.println("\n"+"\n"+"How much would you like to deposit? ");
float depositAmount;
depositAmount = myObj.nextFloat();
amount.balance += depositAmount;
System.out.println("Your total bank balance is: "+"£"+amount.balance);
}
public static void savingsWithdrawal(BankAccount amount){
System.out.println("\n"+"\n"+"How much would you like to withdraw? ");
float withdrawAmount;
withdrawAmount = myObj.nextFloat();
if(withdrawAmount <= 100.0){
if(withdrawAmount < amount.balance) {
amount.balance -= withdrawAmount;
System.out.println("Your account balance is now: "+"£"+amount.balance);
}else{
System.out.println("Sorry you do not have enough in your account. Your account balance is " + "£"+amount.balance);
}
}else{
System.out.println("Sorry you cannot withdraw more than £100");
}
}
public static void savingsBankFees(BankAccount amount){
System.out.println("\n"+"\n"+"Your balance after bank fees of 0% is: " + amount.balance);
}
public static void savingsDisplay(BankAccount amount){
System.out.println("\n"+"\n"+"Account Name: "+ amount.name + "\n" + "Account Number: "+amount.accountNumber + "\n" + "Current Balance: " +"£"+ amount.balance);
}
public static void savingsOverdraft(BankAccount amount){
if(amount.balance <= 0){
System.out.println("\n"+"\n"+"No Overdraft For A Bank Account");
}
}
}
\ 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