Ura BSCS-IIIA
public static Scanner kbd;//Scanner kbd function public static void main(String[] args) {// the main program with the word void doesn't let anything out String userAnswer = null;//declaring the string Scanner kbd = new Scanner(System.in); // declaring the function double accountbalance = 0, depositamount = 0, withdrawalbalance= 0;//declaring the variables, accountbalance, depositamount, withdrawalbalance, as double String acctNum,pwd;//declaring acctNum, pwd as string String acctres;//declaring acctres as string int counter=0;//declaring counter as int int Choice;//declaring Choice as int do//gives the do-while loop the condition to repeat the statement { System.out.println("Please enter your account number: ");//gives the system command to print
acctNum = kbd.nextLine();//getting the inputs and allocating System.out.println("Please enter your account password: ");//gives the system command to print
acctres=checkID(acctNum,pwd);//Initializing acctres
if(!acctres.equals("error"))// checking for the situation of the acctres variable for error
System.out.println("Your Balance is: " + accountbalance + "$");//gives the system command to print
System.out.println("How much would you like to deposit to your account? ");//gives the system command to print
System.out.println("Your Balance with your Deposit now is: " + calculatebalance + "$");//gives the system command to print
System.out.println("How much would you like to withdrawal from your account? ");//gives the system command to print
System.out.println("You Balance now is: " + calculatebalance1 + "$");//gives the system command to print
else// checking for the other inputs except the ones which were mentioned
System.out.println("Do you want to Log Out? (Y or N) ");//gives the system command to print
userAnswer=userAnswer.toUpperCase();//to ignore the upper case or lower case input and count them as the same
if (userAnswer.equals("Y"))//checking for the situation of userAnswer for being equal Y which means yes
else// checking for other input except the ones that already were mentioned
System.out.println("You have exceeded the required amount of times.");//gives the system command to print
public static String checkID(String acctNum, String pwd)//separating the part from the main program as a new function in the main function
String a = "44567-5 mypassword 520.36";//declaring string a which id equal 44567-5 mypassword 520.36 in this function
String b = "12345-6 anotherpassword 48.20";//declaring string b which id equal 12345-6 anotherpassword 48.20 in this function
String c = "54321-0 betterpassword 96.74";//declaring string c which id equal 54321-0 betterpassword 96.74 in this function
return result;//to get data out of the function and takes the value with it only once }
public static double Displaybalance1(double accountbalance)//separating the part from the main program as a new function in the main function {
return accountbalance;//to get data out of the function and takes the value with it only once
public static double Deposit(double accountbalance, double depositamount)//separating the part from the main program as a new function in the main function { return accountbalance+ depositamount;//to get data out of the function and takes the value with it only once }
public static double Withdraw(double accountbalance, double withdrawalbalance)//separating the part from the main program as a new function in the main function { double newbalance1 = 0;//declaring the variables, newbalance1, as double if (withdrawalbalance<=accountbalance)//checking the condition in the parentheses(if withdrawalamount is less than or equal the accontbalance or not) { newbalance1 = accountbalance withdrawalbalance;//gives the system command to print the calculated amount } else if (withdrawalbalance>accountbalance)//checking the condition in the parentheses(if withdrawalamount is more than the accontbalance or not) { newbalance1 = accountbalance;//declaring the newbalance1 as previous accountbalance without change System.out.println("error, that is impossible! your account balance still is: " + newbalance1);//gives the system command to print the accountbalance without changing it }
return newbalance1;//to get data out of the function and takes the value with it only once } public static int Menu()//separating the part from the main program as a new function in the main function
{ int Option ;//declaring the variables, Size, as int do//gives the do-while loop the condition to repeat the statement { Scanner kbd1 = new Scanner(System.in);// declaring the function System.out.println("1. system command to print System.out.println("2. command to print System.out.println("3. command to print System.out.println("4. command to print System.out.println("Enter your option");//gives the system command to print Option = kbd1.nextInt();//getting the inputs and allocating if ((Option<=0)&&(Option > 4))//checking for the statement in parentheses(Smaller or equal 0 or bigger than 4 inputs) { System.out.println("Error! Choose again: ");//gives the system command to print } }while ((Option<=0)&&(Option > 4));//gives the while loop the condition to stop the repeating statement Log Out ");//gives the system Withdraw ");//gives the system Display Balance ");//gives the
return Option;//to get data out of the function and takes the value with it only once } }