Answered step by step
Verified Expert Solution
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
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 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 performedStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started