Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Third International Conference Achids 2011 Daegu Korea April 2011 Proceedings Part 2 Lnai 6592

Authors: Ngoc Thanh Nguyen ,Chong-Gun Kim ,Adam Janiak

2011th Edition

3642200419, 978-3642200410

More Books

Students also viewed these Databases questions