Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

15 points) Solve the following problem a) Write a class that encapsulates the concept of a Jar of Coins, called CoinsJar. The class has instance

image text in transcribed

15 points) Solve the following problem a) Write a class that encapsulates the concept of a Jar of Coins, called CoinsJar. The class has instance variables representing its contents of coins: number of quarters, number of dimes, number of nickels, and number of pennies. The class has a constructor that accepts arguments to initialize the class instance variables. Include accessor and mutator methods for the instance variables. Also include the following methods: A method returning a string representing the total amount in dollar notation with two significant digits after the decimal point. A method returning a string representing the values of each category of coins. For example, if the there are three quarters, two dimes, and five pennies; the method returns a string as The values of each category of coins : Quarters Value: $0.75 Dimes Values: $0.20 Nickels Value: $0.0 Pennies Value: $0.05 A A toString method that returns a string representing the values of the class instance variables. For example, The contents of the Coins Jar are as follows: 3 Quarters, 2 Dimes, 0 Nickels, 5 Pennies b) Write a Java program that uses the CoinsJar class. It reads from an input file the number of coins for quarters, dimes, nickels, and pennies, and uses them to create an object of CoinsJar containing the number of coins read from the file. The program should test the CoinsJar class implementation by: Displaying the contents of the coins' jar. Displaying the total amount in dollar notation of the coins. Displaying the values of each category of coins. Demonstrate the ability of the user to inquire or change the contents of any coin category in the jar, at least once. The program should display the total amount in dollar notation after each update performed

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

A study based on

Answered: 1 week ago