Question: convert Java to C++ rewrite code with C++ import java.awt.Color; import java.awt.Graphics; import java.awt.HeadlessException; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.Timer; public

convert Java to C++

rewrite code with C++

import java.awt.Color;

import java.awt.Graphics;

import java.awt.HeadlessException;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JFrame; import javax.swing.JOptionPane;

import javax.swing.Timer;

public class WithdrawThread extends JFrame implements Runnable { private Account account;

private double amount;

public WithdrawThread(Account account, double amount) {

this.account = account;

this.amount = amount;

setSize(360, 300);

setVisible(true);

setTitle("Withdraw");

setResizable(false);

setDefaultCloseOperation(EXIT_ON_CLOSE); }

public void withdraw(double amount) {

double bal = account.getBalance();

if (amount > bal) {

System.out.print("Wrong amount");

}

bal -= amount;

account.setBalance(bal);

notifyAll();

System.out.print( "Withdraw " + amount + " new balance in thread number " + Thread.currentThread().getId() + " balance is " + bal); }

public synchronized void run() {

try { Thread.sleep(100); }

catch (InterruptedException e) {

e.printStackTrace(); }

try { withdraw(amount);

} catch (InterruptedException e) {

e.printStackTrace(); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!