Skip to content

Featured 250314 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bankAccount/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions bankAccount/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions bankAccount/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>bankAccount</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions bankAccount/src/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
*
*/
/**
*
*/
module bankAccount {
}
61 changes: 61 additions & 0 deletions bankAccount/src/program/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package program;

import java.util.Locale;
import java.util.Scanner;

import utils.Program;

public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

Locale.setDefault(Locale.US);

Program program = new Program();

System.out.println("Enter account number: ");
program.setAccountNumber(sc.nextInt());

sc.nextLine(); //Limpa o buffer

System.out.println("Digite o seu nome: ")
;
program.setAccountName(sc.nextLine());

System.out.println("Quer fazer o depósito inicial (yes/no)?");
String accountQuestion = sc.nextLine();

if(accountQuestion.equals("yes")) {
System.out.println("Digite o depósito inicial: ");
program.setAccountValue(sc.nextDouble());

} else {
System.out.println("Você optou por não fazer o depósito inicial");

}


System.out.println("Account dat"
+ "a: ");
System.out.println("Account " + program.getAccountNumber() + " Holder: " + program.getAccountName() + ", Balance: $" + program.getAccountInicialDeposit());

System.out.println("Enter a deposit value: ");
program.setAccountDeposit(sc.nextDouble());

System.out.println("Updated account data: ");
System.out.println("Account " + program.getAccountNumber() + " Holder: " + program.getAccountName() + ", Balance: $" + program.AccountDepositValue());

System.out.println("Enter a withdraw value: ");
program.setAccountWithdraw(sc.nextDouble());

System.out.println("Updated account data: ");
System.out.println("Account " + program.getAccountNumber() + " Holder: " + program.getAccountName() + ", Balance: $" + program.AccountWithdrawValue());


sc.close();

}

}
82 changes: 82 additions & 0 deletions bankAccount/src/utils/Program.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package utils;

public class Program {

private int accountNumber;
private String accountName;
private double setAccountValue;
private double accountDeposit;
private double accountWithdraw;

// CONSTRUCTOR
public Program() {
}

public Program(int accountNumber, String accountName, double setAccountValue, double accountDeposit,
double accountWithdraw) {
super();
this.accountNumber = accountNumber;
this.accountName = accountName;
this.setAccountValue = setAccountValue;
this.accountDeposit = accountDeposit;
this.accountWithdraw = accountWithdraw;
}

// GETTER AND SETTER

public int getAccountNumber() {
return accountNumber;
}

public void setAccountNumber(int accountNumber) {
this.accountNumber = accountNumber;
}

public String getAccountName() {
return accountName;
}

public void setAccountName(String accountName) {
this.accountName = accountName;
}

public double getAccountInicialDeposit() {
return setAccountValue;
}

public void setAccountValue(double setAccountValue) {
this.setAccountValue = setAccountValue;
}

public double getAccountDeposit() {
return accountDeposit;
}

public void setAccountDeposit(double accountDepoist) {
this.accountDeposit = accountDepoist;
}

public double getAccountWithdraw() {
return accountWithdraw;
}

public void setAccountWithdraw(double accountWithdraw) {
this.accountWithdraw = accountWithdraw;
}

// FUNCTIONS
public double AccountDepositValue() {
return this.setAccountValue + accountDeposit;
}

public double AccountWithdrawValue() {
return AccountDepositValue() - accountWithdraw - 5;
}







}
6 changes: 6 additions & 0 deletions bankAcoount_v2/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions bankAcoount_v2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions bankAcoount_v2/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>bankAcoount_v2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
64 changes: 64 additions & 0 deletions bankAcoount_v2/src/application/Program.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package application;

import java.util.Locale;
import java.util.Scanner;

import entities.Account;

public class Program {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Locale.setDefault(Locale.US);

Account account;

System.out.println("Enter account number: ");
int number = sc.nextInt();

System.out.println("Enter account name: ");
sc.nextLine();
String holder = sc.nextLine();

System.out.println("Is there an anitial deposit (y/n)? ");
char response = sc.next().charAt(0);

if (response == 'y') {
System.out.println("Enter initical deposit value: ");
double intialDeposit = sc.nextDouble();
account = new Account(number, holder, intialDeposit);
} else {
account = new Account(number, holder);
}

System.out.println();
System.out.println("Account data: ");
System.out.println(account);

System.out.println();
System.out.print("Enter a deposit value: ");
double depositValue = sc.nextDouble();
account.deposit(depositValue);

System.out.print("Updated account data: ");
System.out.println(account);

System.out.println();
System.out.print("Enter a withdraw value: ");
double withdrawValue = sc.nextDouble();
account.withdraw(withdrawValue);

System.out.print("Updated account data: ");
System.out.println(account);







sc.close();

}

}
60 changes: 60 additions & 0 deletions bankAcoount_v2/src/entities/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package entities;

public class Account {

private int number;
private String holder;
private double balance;

// CONSTRUCTOR

public Account(int number, String holder) {
this.number = number;
this.holder = holder;
}

public Account(int number, String holder, double initialDeposit) {
this.number = number;
this.holder = holder;
deposit(initialDeposit);
}

// GETTER SETTER
public int getNumber() {
return number;
}

public String getHolder() {
return holder;
}

public void setHolder(String holder) {
this.holder = holder;
}

public double getBalance() {
return balance;
}

// FUNCIONS

public void deposit(double amount) {
balance += amount;
}

public void withdraw(double amount) {
balance -= amount + 5;
}

// TO STRING

public String toString() {
return "Account "
+ number
+ ", Holder: "
+ holder
+ ", Balance: $ "
+ String.format("%.2f", balance);
}

}
8 changes: 8 additions & 0 deletions bankAcoount_v2/src/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
*
*/
/**
*
*/
module bankAcoount_v2 {
}
7 changes: 2 additions & 5 deletions course/src/application/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ public static void main(String[] args) {
System.out.println("Escreva a data do produto ");

System.out.print("Nome: ");
product.name = sc.nextLine();
product.setName(sc.nextLine());

System.out.print("Preço: ");
product.price = sc.nextDouble();

System.out.print("Quantidade no estoque: ");
product.quantity = sc.nextInt();
product.setPrice(sc.nextDouble());

System.out.println();
System.out.print("Dados do produto: " + product.toString());
Expand Down
Loading