Fall 2018 Caldwell CC 2310-Introduction to Computer Softwar Systems ATM Simulati
ID: 3745575 • Letter: F
Question
Fall 2018 Caldwell CC 2310-Introduction to Computer Softwar Systems ATM Simulation Project Using the following algorlthm, design an UML dlagram and write a Java program to simulate the operation of an ATM machine at Caldwell Bank and Trust (CBT). The final project is due Tuesday September 11, 2018 at 2 PM. Your project should have a different dass for each menu Item. Today prior to leaving class you should submit the UML Dlagram. Use JOptionPane for Steps 2-4, Algorithm 1. Start Algorithm 2. Display Welcome Screen 3. Allow user to slide card a. Simulate card sliding by asking user to enter account number Check account number against valid account numbers -if number is invalid allow three attempts then print error message-Please contact your financial institution If number is valid proceed to Step 4. - 4. Allow user to enter personal identification number (PIN) a. Simulate by asking user to enter PINt number i. Check PIN against valid PINs -If number is invalid allow three attempts then print error message-Please contact your financial institution if number is valid proceed to Step 5 5. Display the main menu a. Balance Inquiry b. Fast Cash c. Withdrawal d. Deposit e. Quit 6. Allow user to choose from menu-Assume MyATM is an object a. If choice a proceed to the method to get the balance fi.e. MyATM.get8alance).Explanation / Answer
Note : I will complete this ATM class..Thank You
___________________________
ATM.java
public class ATM {
int[] AccNum = { 1234, 2341, 3412, 4123 };
int[] PIN = { 234, 341, 412, 123 };
int[] InitialBal = { 1000, 2000, 300, 0 };
private int indx;
ATM()
{
}
public int checkAccountNum(int accNo)
{
for(int i=0;i<AccNum.length;i++)
{
if(accNo==AccNum[i])
{
indx=i;
return i;
}
}
return -1;
}
public int checkPin(int p) {
if(PIN[indx]==p)
return 1;
else
return -1;
}
public double getBalance() {
return InitialBal[indx];
}
}
_______________
package org.students;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
char choice;
int accountNum, n = 0,res = 0,p,res1=0;
/*
* Creating an Scanner class object which is used to get the inputs
* entered by the user
*/
Scanner sc = new Scanner(System.in);
System.out.println("** Welcome to the ATM **");
ATM myATM=new ATM();
while (n < 3) {
// Getting the input entered by the user
System.out.print("Enter the account number :");
accountNum = sc.nextInt();
res=myATM.checkAccountNum(accountNum);
if (res == -1) {
if(n<3)
System.out.println("Invalid Account Number.Try Again");
n++;
} else {
break;
}
}
if(n==3)
{
System.out.println("** Please contact your financial institution **");
System.exit(0);
}
n=0;
while(n<3)
{
System.out.print("Enter PIN :");
p=sc.nextInt();
res1=myATM.checkPin(p);
if (res1 == -1) {
if(n<3)
System.out.println("Invalid PIN.Try Again");
n++;
} else {
break;
}
}
if(n==3)
{
System.out.println("** Please contact your financial institution **");
System.exit(0);
}
while(true)
{
System.out.println("a.Balance Enquiry");
System.out.println("b.fast Cash");
System.out.println("c.Withdrawl");
System.out.println("d.Deposit");
System.out.println("e.Quit");
choice=sc.next(".").charAt(0);
switch(choice)
{
case 'a':
case 'A':
{
System.out.println("Your Account Balance :$"+myATM.getBalance());
continue;
}
case 'b':
case 'B':
{
continue;
}
case 'c':
case 'C':
{
continue;
}
case 'd':
case 'D':
{
continue;
}
case 'e':
case 'E':
{
break;
}
default:{
System.out.println("** Invalid Choice **");
continue;
}
}
break;
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.