السلام عليكم
هده اول مشاركة لي في هدا المنتدي . واتمنى ان تستفيدو مني واستفد منكم
انا ادرس لغة الجافا في احد الكليات ونضرا لصعوبة هدة اللغة و الله ما قدرت استوعبها الاني من المبتدئين
ولدي مشروع بسيط ليس للتخرج بس اعمال سنة
واريد من حضراتكم ان تساعدوني
البرنامج هوى عبارة منضومة سحب داتي الخاصة بالمصارفATM
العمليات عليها عرض قيمة الحساب والسحب و الايداع
لدي برنامج جاهز لهدة المنضومة بس المشكلة ان المنضومة تستخدم مكتية باسم import java.util.Scanner; واحنى ما درسنى هدة المكتبة
ولا اعرف فادتها الاننا نستخدم في مكتبات عادية .
المطلوب :
1-اريد تعديل هدة المنضوة بحيت انني لا استخدم المكتبة java.util.Scanner
2-اريد شرح عملية المنضومة قبل التعديل وبعد التعديل ولو بشكل مبسط .
3- ادا كان لديكم اي تغير لهدة المنضومة بشكل كامل ومبسط جدا فلا بأس .
4- ما فائدة هدة المكتبة
طبعا هدة المنضومة بالغة جافا تطبيقات . المشغل الي استخدمة هوى Bluej
وهدا هوا البرنامج
اتمني انني لم اطل عليكم باطلباتي
ولكم جزيل الشكر
import java.util.Scanner;
/*----------------------------1----------------------------*/
public class AtmMachine
{
private double availableBal =1000;
private double totalBal =1300;
Scanner input = new Scanner(System.in);
/*--------------------------------------------------------*/
public int userAccount()
{
System.out.print("Enter your account number: ");
int account;
account = input.nextInt();
return account;
}
/*----------------------------2----------------------------*/
public int userPin()
{
System.out.print("Enter your pin number: ");
int pin;
pin =input.nextInt();
return pin;
}
/*---------------------------3-----------------------------*/
public void startAtm()
{
userAccount();
userPin();
drawMainMenu();
}
/*----------------------------4----------------------------*/
public void drawMainMenu()
{
int selection;
System.out.println("\nATM main menu:");
System.out.println("1 - View account balance");
System.out.println("2 - Withdraw funds");
System.out.println("3 - Add funds");
System.out.println("4 - Terminate transaction");
System.out.print("Choice: ");
selection =input.nextInt();
switch(selection)
{
case 1:
viewAccountInfo();
break;
case 2:
withdraw();
break;
case 3:
addFunds();
break;
case 4:
System.out.println("Thank you for using this ATM!!! goodbye");
}
}
/*---------------------------5-----------------------------*/
public void viewAccountInfo()
{
System.out.println("Account Information:");
System.out.println("\t--Total balance: {:content:}quot;+totalBal);
System.out.println("\t--Available balance: {:content:}quot;+availableBal);
drawMainMenu();
}
/*---------------------------6-----------------------------*/
public void deposit(int depAmount)
{
System.out.println("\n***Please insert your money now...***");
totalBal =totalBal +depAmount;
availableBal =availableBal +depAmount;
}
/*---------------------------7-----------------------------*/
public void checkNsf(int withdrawAmount)
{
if(totalBal -withdrawAmount < 0)
System.out.println("\n***ERROR!!! Insufficient funds in you accout***");
else
{
totalBal =totalBal -withdrawAmount;
availableBal =availableBal -withdrawAmount;
System.out.println("\n***Please take your money now...***");
}
}
/*---------------------------8-----------------------------*/
public void addFunds()
{
int addSelection;
System.out.println("Deposit funds:");
System.out.println("1 - $100");
System.out.println("2 - $200");
System.out.println("3 - $300");
System.out.println("4 - $500");
System.out.println("5 - $800");
System.out.println("6 - Back to main menu");
System.out.print("Choice: ");
addSelection =input.nextInt();
switch(addSelection)
{
case 1:
deposit(100);
drawMainMenu();
break;
case 2:
deposit(200);
drawMainMenu();
break;
case 3:
deposit(300);
drawMainMenu();
break;
case 4:
deposit(500);
drawMainMenu();
break;
case 5:
deposit(800);
drawMainMenu();
break;
case 6:
drawMainMenu();
break;
}
}
/*----------------------------9----------------------------*/
public void withdraw()
{
int withdrawSelection;
System.out.println("Withdraw money:");
System.out.println("1 - $20");
System.out.println("2 - $40");
System.out.println("3 - $60");
System.out.println("4 - $100");
System.out.println("5 - Back to main menu");
System.out.print("Choice: ");
withdrawSelection =input.nextInt();
switch(withdrawSelection)
{
case 1:
checkNsf(20);
drawMainMenu();
break;
case 2:
checkNsf(40);
drawMainMenu();
break;
case 3:
checkNsf(60);
drawMainMenu();
break;
case 4:
checkNsf(100);
drawMainMenu();
break;
case 5:
drawMainMenu();
break;
}
}
/*-----------------------------10---------------------------*/
public static void main(String args[])
{
System.out.println("\tATM BANK \n_______________________________________");
AtmMachine myAtm = new AtmMachine();
myAtm.startAtm();
}
}