You are to write a Java program using the following instructions to build a bank-ATM server system with sockets.
A bank holds accounts that can have deposits, withdrawals, or retrievals of balance. The bank server provides the account for transactions when a client uses and ATM machine. The ATM asks for the type of transaction and the amount (if needed), then creates a socket connection to the bank to send the transaction for processing. The bank performs the transaction on the account and returns the balance to the client at the ATM. The following are some vague descriptions of the various packages, classes, etc., that the program must have. You will have to make your own decisions on how to approach it.
Server
Client
You can see an example of expected output here:
https://web.microsoftstream.com/video/662fcb3d-cf43-4164-a74b-6187dfc8aff6
Made a simple java program for ATM server: import java.util.*; public class ATM { public static Scanner kbd = new Scanner(System.in); // The checkID method determines if acctNum is a valid account number // and pwd is the correct password for the account. If the account information // is valid, the method returns the current account balance, as a string. // If the account information is invalid, the method returns the string "error". public static String checkID(String acctNum, String pwd) { String result = "error"; // Strings a, b, and c contain the valid account numbers and passwords. // For each string, the account number is listed first, followed by // a space, followed by the password for the account, followed by a space, // followed by the current balance. String a = "44567-5 mypassword 520.36"; String b = "1234567-6 anotherpassword 48.20"; String c = "4321-0 betterpassword 96.74"; if (acctNum.equals(a.substring(0, a.indexOf(" "))) && pwd.equals(a.substring(a.indexOf(" ")+1,a.lastIndexOf(" ")))) return result = a.substring(a.lastIndexOf(" ") + 1); if (acctNum.equals(b.substring(0, b.indexOf(" "))) && pwd.equals(b.substring(b.indexOf(" ")+1,b.lastIndexOf(" ")))) return result = b.substring(b.lastIndexOf(" ") + 1); if (acctNum.equals(c.substring(0, c.indexOf(" "))) && pwd.equals(c.substring(c.indexOf(" ") + 1,c.lastIndexOf(" ")))) return result = c.substring(c.lastIndexOf(" ") + 1); return result; } public static int menu() { int menuChoice; do { System.out.print("\nPlease Choose From the Following Options:" + "\n 1. Display Balance \n 2. Deposit" + "\n 3. Withdraw\n 4. Log Out\n\n"); menuChoice = kbd.nextInt(); if (menuChoice < 1 || menuChoice > 4){ System.out.println("error"); } }while (menuChoice < 1 || menuChoice > 4); return menuChoice; } public static void displayBalance(double x) { System.out.printf("\nYour Current Balance is $%.2f\n", x); } public static double deposit(double x, double y) { double depositAmt = y, currentBal = x; double newBalance = depositAmt + currentBal; System.out.printf("Your New Balance is $%.2f\n", newBalance); return newBalance; } public static double withdraw(double x, double y) { double withdrawAmt = y, currentBal = x, newBalance; newBalance = currentBal - withdrawAmt; System.out.printf("Your New Balance is %.2f\n",newBalance); return newBalance; } public static void main(String[] args) { String accNum, pass, origBal = "error"; int count = 0, menuOption = 0; double depositAmt = 0, withdrawAmt = 0, currentBal=0; boolean foundNonDigit; //loop that will count the number of login attempts //you make and will exit program if it is more than 3. //as long as oriBal equals an error. do{ foundNonDigit = false; System.out.println("Please Enter Your Account Number: "); accNum = kbd.next(); System.out.println("Enter Your Password: "); pass = kbd.next(); origBal = checkID(accNum, pass); count++; if (count >= 3 && origBal.equals("error")){ System.out.print("Maximum Login Attempts Reached."); System.exit(0); } if (!(origBal.equals("error"))){ System.out.println("\nYour New Balance is: $ "+ origBal); } else System.out.println(origBal); }while(origBal.equals("error")); currentBal=Double.parseDouble(origBal); //this loop will keep track of the options that //the user inputs in for the menu. and will //give the option of deposit, withdraw, or logout. while (menuOption != 4) { menuOption=menu(); switch (menuOption) { case 1: displayBalance(currentBal); break; case 2: System.out.print("\nEnter Amount You Wish to Deposit: $ "); depositAmt = kbd.nextDouble(); currentBal=deposit(depositAmt, currentBal); break; case 3: System.out.print("\nEnter Amount You Wish to Withdrawl: $ "); withdrawAmt = kbd.nextDouble(); while(withdrawAmt>currentBal){ System.out.print("ERROR: INSUFFICIENT FUNDS!! " + "PLEASE ENTER A DIFFERENT AMOUNT: $"); withdrawAmt = kbd.nextDouble(); } currentBal = withdraw(currentBal, withdrawAmt); break; case 4: System.out.print("\nThank For Using My ATM. Have a Nice Day. Good-Bye!"); System.exit(0); break; } } } }
You are to write a Java program using the following instructions to build a bank-ATM server...
Need help creating a Java program with mandatory requirements! VERY IMPORTANT: The George account class instance must be in the main class, and the requirement of printing a list of transactions for only the ids used when the program runs(Detailed in the Additional simulation requirements) is extremely important! Thank you so very much! Instructions: This homework models after a banking situation with ATM machine. You are required to create three classes, Account, Transaction, and the main class (with the main...
I have to modify a server program and chat program to work as the following instructions but I am completely clueless as to where to start. I'd appreciate any help on how to atleast get started. This must be done in java. Diffie-Hellman Two parties use a key agreement protocol to generate identical secret keys for encryption without ever having to transmit the secret key. The protocol works by both parties agreeing on a set of values (a) and (q)....
Congratulations, you have been hired by Shaky Bank and Trust as a staff programmer. Your task for this assignment is to create a simple bank accounting system and demonstrate its use. Create an Account class as per the following specifications: three private instance variables: accountOwnerName (String), accountNumber (int) and balance (double) a single constructor with three arguments: the account owner's name, accountNumber and starting balance. In the constructor, initialize the instance variables with the provided parameter values. get and set...
I need help with my IM (instant messaging) java program, I created the Server, Client, and Message class. I somehow can't get both the server and client to message to each other. I am at a roadblock. Here is the question below. Create an IM (instant messaging) java program so that client and server communicate via serialized objects (e.g. of type Message). Each Message object encapsulates the name of the sender and the response typed by the sender. You may...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
Java Question 3 Implement a program to store the applicant's information for a visa office. You need to implement the following: A super class called Applicant, which has the following instance variables: A variable to store first name of type String. A variable to store last name of type String. A variable to store date of birth, should be implemented as another class to store day, month and year. A variable to store number of years working of type integer...
Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...
Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...
ATM Revisited In Java, design a subclass of the Account class called GoldAccount. It is still an Account class, however it has an additional field and some additional functionality. But it will still retain all the behavior of the Account class. Write a class called GoldAccount. This class will have an additional private field called bonusPoints. This field will require no get or set methods. But it will need to be initialized to 100 in the constructor. Thereafter, after a...
In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...