You are to program a virtual ATM machine. The client wants java GUI for its virt
ID: 3574952 • Letter: Y
Question
You are to program a virtual ATM machine. The client wants java GUI for its virtual ATM. The program will allow a user to enter their personal pin number (only 4 numbers allowed from 0100 to 8888). The user then must choose which account they would like to make a transaction: Savings Account or Checking Account, or Loan Payment (such as a mortgage, a car loan, or a student loan). If the user chooses a savings account, then the allowed transactions are either to add money to the saving account, or to withdraw money from the savings account. A balance must be given to the user at the end of the transaction. Assume that the user has a starting balance of $3000 in each of their checking and savings accounts. Error trapping: if a balance goes below $500, then an alert to the user will be issued.
For the loan payments, the user is to choose whether the loan is for a mortgage, a student loan, an auto loan, or a personal loan. For Mortgage: assume $250,000 balance and payment of $2000 per month; For Student Loan: assume $55,000 balance and payment of $200 per month; For Auto Loan, assume $45,000 balance and payment of $500 per month; For Personal Loan, assume $4,000 and payment of $1000 per month.
Test data: for savings account in order: deposit $1000, deposit $500, withdraw $2000, final balance
Test data for checking account in order: checks (in order) made in the amount of $112, $30, $680, $150, $1000, final balance.
Test data for loan payment(s): see above and provide for at least two payments.
Please answer ASAP! Thank you!!!
Explanation / Answer
Solution:
/* Java Code */
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
@SuppressWarnings("serial")
public class D_loanGui extends JFrame implements ActionListener
{
JLabel lbl=new JLabel("Are you making a payment on your loan",SwingConstants.CENTER);
JPanel pnlC=new JPanel();
JPanel buttons=new JPanel();
JButton y=new JButton("Yes");
JButton n=new JButton("No");
public D_loanGui()
{
super("Loan Payment");
setSize(300,150);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pnlC.setLayout(new BorderLayout());
pnlC.add(lbl, BorderLayout.CENTER);
pnlC.add(buttons, BorderLayout.SOUTH);
buttons.add(y);
buttons.add(n);
y.addActionListener(this);
n.addActionListener(this);
add(pnlC);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()= =y)
{
String input=JOptionPane.showInputDialog(new JFrame(), "How much are you paying on your loan?");
if(input!=null)
{
Double res=Double.parseDouble(input);
Z_Client.makeLoanPayment(res);
JOptionPane.showMessageDialog(new JFrame(),Z_Client.displayLoan());
int selectedOption = JOptionPane.showConfirmDialog(null, "Are you done with your transaction?", "Choose", JOptionPane.YES_NO_OPTION);
if (selectedOption == JOptionPane.YES_OPTION)
{
this.dispose();
}
else
{
JOptionPane.showMessageDialog(new JFrame(),"<html>"+Z_Client.displayCheck()+<br>"+Z_Client.displaySav()+"<br>"+Z_Client.displayLoan()+"</html>");
}
}
}
else
if(e.getSource()= =n)
{
this.dispose();
}
}
}
C++ code
//.h file code:
#include <string>
#include <boost/optional.hpp>
//@SuppressWarnings("serial") public class D_loanGui extends JFrame implements
class D_loanGui : public JFrame, public ActionListener
{
public:
JLabel *lbl = new JLabel(L"Are you making a payment on your loan",SwingConstants::CENTER);
JPanel *pnlC = new JPanel();
JPanel *buttons = new JPanel();
JButton *y = new JButton(L"Yes");
JButton *n = new JButton(L"No");
D_loanGui();
virtual void actionPerformed(ActionEvent *e) override;
};
//.cpp file code:
D_loanGui::D_loanGui() : JFrame(L"Loan Payment")
{
setSize(300,150);
setDefaultCloseOperation(EXIT_ON_CLOSE);
BorderLayout tempVar();
Cout << "setLayout(&tempVar)";
Cout << " add(lbl, BorderLayout::CENTER);
Cout << "add(buttons, BorderLayout::SOUTH" ;
buttons->add(y);
buttons->add(n);
y->addActionListener(this);
n->addActionListener(this);
add(pnlC);
setVisible(true);
}
void D_loanGui::actionPerformed(ActionEvent *e)
{
if (e->getSource() == y)
{
JFrame tempVar();
std::wstring input = JOptionPane::showInputDialog(&tempVar, L"How much are you paying on your loan?");
if (input != L"")
{
boost::optional<double> res = std::stod(input);
Z_Client::makeLoanPayment(res);
JFrame tempVar2();
JOptionPane::showMessageDialog(&tempVar2,Z_Client::displayLoan());
int selectedOption = JOptionPane::showConfirmDialog(nullptr, L"Are you done with your transaction?", L"Choose", JOptionPane::YES_NO_OPTION);
if (selectedOption == JOptionPane::YES_OPTION)
{
this->dispose();
}
else
{
JFrame tempVar3();
JOptionPane::showMessageDialog(&tempVar3,std::wstring(L"<html>") + Z_Client::displayCheck() + std::wstring(L"<br>") + Z_Client::displaySav() + std::wstring(L"<br>") + Z_Client::displayLoan() + std::wstring(L"</html>"));
}
}
}
else if (e->getSource() == n)
{
this->dispose();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.