Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

project in called Assignment07. Call this program MonetaryCoinTester (this will contain the main method). Create two other classes called MonetaryCoin and Coin, respectively (there will

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
project in called Assignment07. Call this program MonetaryCoinTester (this will contain the main method). Create two other classes called MonetaryCoin and Coin, respectively (there will be no main method within these classes). You are to use Guls for your output in your program. Specifically you are to use option panes from the swing class, so you will have to import the javax.swing package into your program to do this. You are to use the class NumberFormat for formatting numbers so you should import this class too. First thing you should do, open the file called MonetaryCoinTester from Files/AssignmentDataFiles and copy it into the program you created above (i.e. you will overwrite it). Do the same for the files called Monetarycoin and Coin. Design and implement a class called MonetaryCoin that is derived from the Coin class presented in the chapter Conditionals and Loops. Store an integer in the MonetaryCoin that represents its value and add a method that returns its value. Create a main driver class to instantiate and compute the sum of several MonetaryCoin objects. Demonstrate that a monetary coin inherits its parent's ability to be flipped. public class MonetaryCoin extends Coin { // child clasg // declare an instance field that // represents the value of a coin public MonetaryCoin (int money) // invoke the parent's constructor } // end constructor Monetary public int getValue() // only if and only if it is // heads do we return its value // otherwise, do not return // its value } return -1; // to be modified // end method getValue public String toString() String result, coinType; // invoke parent's toString method // to begin building a string // concatenate correct wording // associated with the coin // complete the string return ""; // to be modified // end method toString H) } // end class MonterayCoin import javax.swing.; import java.text.Number Format; public class MonetaryCointester ! public static void main(String[] args) { // declare an array from the // MonetaryCoin class to // represent different coins 77 declare local variables to be // used in our program double gum = 0.0; String output; // for formatting nice numbers 77 instantiate each element of the array // 'coins' and pass to the constructor // the value of that coin (each coin // will be flipped one at a time) // flip all the coins again // compute the total value of the coins // with heads only // prepare string for display output = "Flip outcome for all coins: "; // format our total cum nicely // display final result! } // end method main // end class MonetaryCoinTester } public class Coin { // parent class 17 declare instance field // to be used in program 7 (1.e. the face of the coin) public Coin() } // end constructor // flip the coin by randomly choosing a value public void flip } /end method flip public int get Face return -1; // to be modified // end method get Face } public String toString() // parent's toString method String faceName = ""; return ""; // to be modified // end method toString H end class Coin 1

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Discuss the history of human resource management (HRM).

Answered: 1 week ago