Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Only needing help on part B. I've already solved part A, just pretty rusty with the read file aspects of java. There is no input

image text in transcribedOnly needing help on part B. I've already solved part A, just pretty rusty with the read file aspects of java. There is no input file given, but I believe the professor prefers the to utilize scanner for file reading. Thanks!

1. (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 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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

In exercises find (x) = 1/x 2 lim x-0 f(x + 4x) - f(x)

Answered: 1 week ago

Question

Consistently develop management talent.

Answered: 1 week ago

Question

Create a refreshed and common vision and values across Europe.

Answered: 1 week ago

Question

Provide the best employee relations environment.

Answered: 1 week ago