Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package atm;
- import javax.swing.JOptionPane;
- public class ATM {
- public static void main(String[] args) {
- int i; //switch(هذا لل)
- int ps; //الباسورد المدخل
- double balance = 1000.0;
- int pw = 1234;
- double amount; //نخزنوا فيه القيم ألي نبو نسحبوهن و نودعوهن
- String input = JOptionPane.showInputDialog(null,"input password");
- ps = Integer.parseInt(input); //القيمة المدخلة من نوع سترينق فانحولها انتجير
- if (pw == ps)
- input = JOptionPane.showInputDialog(null,"choose option\n1:withdraw\n2:deposit\n3:check balance");
- i = Integer.parseInt(input); // نخزنوا قيمة الاختيار في أي و انحولوها ألى انتجير
- switch(i){
- case 1: //في حالت السحب
- input = JOptionPane.showInputDialog(null,"input amount");
- amount = Integer.parseInt(input); //انسجلوا قيمة السحب كانتيجر
- if (amount <= balance){
- balance -= amount; //انقصوا من الحساب قبل ما نطبعوه
- JOptionPane.showMessageDialog(null, "Successful, new balance: "+balance);
- }else{ JOptionPane.showMessageDialog(null, "error");}
- break;
- case 2:
- input = JOptionPane.showInputDialog(null,"input amount");
- amount = Integer.parseInt(input);
- balance += amount;
- JOptionPane.showMessageDialog(null, "Successful, new balance: "+balance);
- break;
- case 3:
- JOptionPane.showMessageDialog(null, "balance: "+balance);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement