atm-projects-'s People
atm-projects-'s Issues
ATM Projects in Java
H
ATM.java
ATM.java
package saylee;
import java.util.Scanner;
class BankAccount {
private double balance;
public BankAccount(double balance) {
this.balance = balance;
}
public double getBalance() {
return balance;
}
public void deposit(double amount) {
balance += amount;
System.out.println("Deposit successful. Current balance: " + balance);
}
public void withdraw(double amount) {
if (balance >= amount) {
balance -= amount;
System.out.println("Withdrawal successful. Current balance: " + balance);
} else {
System.out.println("Insufficient funds. Withdrawal failed.");
}
}
}
public class ATM {
private BankAccount account;
private Scanner scanner;
public ATM(BankAccount account) {
this.account = account;
this.scanner = new Scanner(System.in);
}
public void displayMenu() {
System.out.println("Welcome to the ATM");
System.out.println("1. Check Balance");
System.out.println("2. Deposit");
System.out.println("3. Withdraw");
System.out.println("4. Exit");
System.out.print("Enter your choice: ");
}
public void processChoice(int choice) {
switch (choice) {
case 1:
checkBalance();
break;
case 2:
deposit();
break;
case 3:
withdraw();
break;
case 4:
System.out.println("Thank you for using ATM");
System.exit(0);
default:
System.out.println("Invalid choice. Please try again.");
}
}
public void checkBalance() {
System.out.println("Your balance is: " + account.getBalance());
}
public void deposit() {
System.out.print("Enter deposit amount: ");
double amount = scanner.nextDouble();
if (amount > 0) {
account.deposit(amount);
} else {
System.out.println("Invalid amount. Deposit failed.");
}
}
public void withdraw() {
System.out.print("Enter withdrawal amount: ");
double amount = scanner.nextDouble();
if (amount > 0) {
account.withdraw(amount);
} else {
System.out.println("Invalid amount. Withdrawal failed.");
}
}
public static void main(String[] args) {
BankAccount userAccount = new BankAccount(1000); // Initialize user's account with a balance of 1000
ATM atm = new ATM(userAccount);
while (true) {
atm.displayMenu();
int choice = atm.scanner.nextInt();
atm.processChoice(choice);
}
}
}
GradeCalculator.java
package saylee;
import java.util.Scanner;
public class GradeCalculator {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
System.out.println("Student Grade Calculator");
System.out.print("Enter number of subjects: ");
int numSubjects = scanner.nextInt();
int totalMarks = 0;
for (int i = 1; i <= numSubjects; i++) {
System.out.print("Enter marks obtained in subject " + i + ": ");
int marks = scanner.nextInt();
totalMarks += marks;
}
double averagePercentage = (double) totalMarks / numSubjects;
System.out.println("Total Marks: " + totalMarks);
System.out.println("Average Percentage: " + averagePercentage + "%");
String grade = calculateGrade(averagePercentage);
System.out.println("Grade: " + grade);
}
public static String calculateGrade(double averagePercentage) {
if (averagePercentage >= 90) {
return "A+";
} else if (averagePercentage >= 80) {
return "A";
} else if (averagePercentage >= 70) {
return "B";
} else if (averagePercentage >= 60) {
return "C";
} else if (averagePercentage >= 50) {
return "D";
} else {
return "F";
}
}
}
Readme projects
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.