Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public static void main ( String args [ ] ) { Wallet w 0 = new Wallet ( ) ; Wallet w 1 = new

public static void main(String args[]){ Wallet w0= new Wallet(); Wallet w1= new Wallet(1,2,3,4); int value; System.out.println("w0:"); w0.printContents(); value = w0.getValue(); System.out.println("value ="+ value +"
"); System.out.println("w1:"); w1.printContents(); value = w1.getValue(); System.out.println("value ="+ value +"
"); System.out.println("adding $50 to w0"); w0.add(2,1,0,0); System.out.println("w0:"); w0.printContents(); value = w0.getValue(); System.out.println("value ="+ value +"
"); System.out.print("Comparing w0 and w1: "); w0.compare(w1); System.out.println("
Adding $9 to w0"); w0.add(0,0,1,4); System.out.println("w0:"); w0.printContents(); value = w0.getValue(); System.out.println("value ="+ value +"
"); System.out.print("Comparing w0 and w1: "); w0.compare(w1); System.out.println("
Adding $1 to w0"); w0.add(0,0,0,1); System.out.println("w0:"); w0.printContents(); value = w0.getValue(); System.out.println("value ="+ value +"
"); System.out.print("Comparing w0 and w1: "); w0.compare(w1); System.out.println("
Adding contents of w1 into w0"); w0.add(w1); System.out.println("w0:"); w0.printContents(); value = w0.getValue(); System.out.println("value ="+ value +"
"); System.out.println("w1:"); w1.printContents(); value = w1.getValue(); System.out.println("value ="+ value +"
"); System.out.println("Creating a new Wallet"); Wallet w2= new Wallet(5,4,3,2); System.out.println("w2:"); w2.printContents(); value = w2.getValue(); System.out.println("value ="+ value +"
"); System.out.println("Subtracting $210"); w2= w2.subtract(210); System.out.println("w2:"); w2.printContents(); value = w2.getValue(); System.out.println("value ="+ value +"
"); System.out.println("Oops, let's try $120"); w2= w2.subtract(120); System.out.println("w2:"); w2.printContents(); value = w2.getValue(); System.out.println("value ="+ value +"
"); System.out.println("Subtracting $14"); w2= w2.subtract(14); System.out.println("w2:"); w2.printContents(); value = w2.getValue(); System.out.println("value ="+ value +"
"); }}= OUTPUT ============================================================w0:twenties =0, tens =0, fives =0, ones =0value =0w1:twenties =1, tens =2, fives =3, ones =4value =59adding $50 to w0w0:twenties =2, tens =1, fives =0, ones =0value =50Comparing w0 and w1: IS LESS THANAdding $9 to w0w0:twenties =2, tens =1, fives =1, ones =4value =59Comparing w0 and w1: IS EQUAL TOAdding $1 to w0w0:twenties =2, tens =1, fives =1, ones =5value =60Comparing w0 and w1: IS GREATER THANAdding contents of w1 into w0w0:twenties =3, tens =3, fives =4, ones =9value =119w1:twenties =0, tens =0, fives =0, ones =0value =0Creating a new Walletw2:twenties =5, tens =4, fives =3, ones =2value =157Subtracting $210Insufficient funds - purchase denied.w2:twenties =5, tens =4, fives =3, ones =2value =157Oops, let's try $120w2:twenties =1, tens =1, fives =1, ones =2value =37Subtracting $14w2:twenties =1, tens =0, fives =0, ones =3value =23

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions