Can you please help me with creating this Java Code using the following pseudocode?
Make Change Calculator (100 points + 5 ex.cr.) 2019
In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you will re-do the program to give change from a specific number of available coins.
Part A: Basic Change for a dollar:
In this version of the program you will give change for up to a dollar in the most efficient manner (i.e., fewest number of coins of each type).
A sample run of the program might look as follows:
Welcome to the Make Change calculator!
What value would you like change for? (1-100 cents, or 0=quit): 23
For 23 cent(s) I give: 0 quarters, 2 dimes, 0 nickels, 3 pennies
What value would you like change for? (1-100 cents, or 0=quit): 1
For: 1 cent(s) I give: 0 quarters, 0 dime, 0 nickels, 1 pennies
What value would you like change for? (1-100 cents, or 0=quit): 100
For: 100 cent(s) I give: 4 quarters, 0 dime, 0 nickels, 0 pennies
What value would you like change for? (1-100 cents, or 0=quit): 0
Thanks for using the Make Change calculator!
Part A Required Elements: the following features must be present for full credit:
Part B: Perfect change with specific coin counts:
The claim has been made that when receiving change for any amount up to and including $1 you can always make that change with only the following coins: 3 quarters, 1 dime, 2 nickels, and 5 pennies. You will write a program to test that assumption. To do this, you will add a method to the program that runs at the beginning to ask if a specific set of coins is being used (but note that the program may still run in the old way also). The user will then have the option, during operation, to switch back and forth between using a ‘coin set’ or not (i.e., just running the Part A method). A sample run might be as follows:
Welcome to the Make Change calculator!
Do you have a specific set of coins for making change? (Y/N): Y
No. of Quarters: 3
No. of Dimes: 1
No. of Nickels: 2
No. of Pennies: 5
What value would you like change for? (1-100 cents, 101=New Coin set, or 0=quit): 23
For 23 cent(s) I give:
0 quarters, 1 dime, 2 nickels, 3 pennies leaving
3 quarters, 0 dime, 0 nickels, 2 pennies
What value would you like change for? (1-100 cents, 101=New Coin set, or 0=quit): 100
For: 100 cent(s) I give:
3 quarters, 1 dime, 2 nickels, 5 pennies leaving:
0 quarters, 0 dime, 0 nickels, 0 pennies
What value would you like change for? (1-100 cents, 101=New Coin set, or 0=quit): 101
Do you have a specific set of coins for making change? (Y/N): Y
No. of Quarters: 3
No. of Dimes: 1
No. of Nickels: 2
No. of Pennies: 2
What value would you like change for? (1-100 cents, 101=New Coin set, or 0=quit): 4
I could not make change for: 4 cents (I am short: 2 cents)
What value would you like change for? (1-100 cents, 101=New Coin set, or 0=quit): 0
Thanks for using the Make Change calculator!
In this version the ‘how much change’ question now has a new option: 101. If the user selects this option, the program should run the method that asks if a coin set is being used and, if the operator answers yes, then asks for the specific coin counts (i.e., the same method that now runs at the beginning of the program). If the operator says no, the program returns to the ‘Part A’ version (i.e., giving the fewest possible coins as change for $1).
Now during operation, the program must know if a specific set of coins has been entered: if so, then a new method called ‘PerfectChange’ will be used to determine the coins to be given. This also means that the user may go back and forth between using a coin set and not. By using option 101 but answering ‘N’ to the ‘Do you have a specific set of coins’ the user effectively turns off the PerfectChange feature and returns to making change in the most efficient way possible.
Also note that in the ‘specific coins’ scenario, it is possible that perfect change cannot be given (see sample run above).
Call the program MakeChange.java and zip the finished netbeans project from the top-level folder. Submit it through blackboard as a separate zip file, as discussed in class.
Extra Credit (5 points):
Add another option to the ‘how much change’ question (i.e., add an item 102) that produces an ‘all’ output result. Thus, if the user enters 102, the program should loop to produce results for all values 1 through 100 (using the coin counts if entered or the original ‘most efficient’ method – whichever is currently selected in the program). This option should not fundamentally modify any of the existing methods in the program, but merely add a new method to loop through all possible values from 1 – 100 (making use of the other program methods, as needed). New parameter passing may be needed for this operation, depending on program structure
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Make Change Program (Part A)
Imports:
java.util.Scanner
Global Variables:
Scanner sc – scanner object to read System.in
Methods:
static void main(String[] args) – process control with loop for multiple runs
static int getCents() – obtain and validate input of change being requested
static void makeChange(int cents) – calculate and display coins given in change
Process:
main(String[] args):
local variables: int cents – variable for change amount being requested
getCents():
local variables: int c – cents input value to return
while (c < 0 or c > 100)
makeChangeAddMethod(int cents):
local variables: int q,d,n,p – for quarters, dimes, nickels, pennies to give
int t – working variable for total cents
makeChangeDivMethod(int cents):
local variables: int q,d,n,p – for quarters, dimes, nickels, pennies to give
int r – working variable for ‘remaining cents’ to give
Part B
Global Variables:
Add: int qoh, doh, noh, and poh for Quarters-on-Hand, Dimes-on-Hand, Nickels-on-Hand, and Pennies-on-Hand
Methods:
Add: boolean getCoinSet() – to determine if a coinset is being used and
to validate and return coins on hand for each ‘cointype’ (if yes)
Add: int getCoins(String cointype) – to obtain a specific value for a type of coin on hand
Specific method changes:
main():
Boolean getCoinSet():
Int getCoins(String cointype):
Code is virtually the same as getCoins method from prior assignment (calcChange)
perfectChange(int cents):
Changes to algorithm: basic process is the same, except after determining each coin count, value must be checked against coins on hand, and adjusted accordingly. So, for prior step 2 you would now have:
Determine Quarters to give:
The final step (print results) must also check that r has been worked down to zero: if not, perfect change could not be given from the available set of coins.
import java.util.*;
class ChangeMaker
{
static int quarters;
static int dimes;
static int pennies;
static int nickels;
public static void makeChange(int cents)
{
quarters = cents / 25;
cents %= 25;
dimes = cents / 10;
cents %= 10;
nickels = cents / 10;
cents %= 5;
pennies = cents;
}
public static void main(String[] args)
{
System.out.println("Welcome to the Make Change calculator!");
System.out.print("What value would you like change for? (1-100
cents, or 0=quit): ");
Scanner sc = new Scanner(System.in);
int cents = sc.nextInt();
while(cents != 0)
{
makeChange(cents);
System.out.println("For " + cents + " cent(s) I give: " + quarters
+ " quarters, " + dimes + " dimes, " + nickels + " nickels, " +
pennies + " pennies");
System.out.print("What value would you like change for? (1-100
cents, or 0=quit): ");
cents = sc.nextInt();
}
}
}
Can you please help me with creating this Java Code using the following pseudocode? Make Change C...
(In Python 3) Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes So...
Given a value V in cents, you need to make change using a minimum number of coins. Assume you have an infinite supply of quarters, nickels, dimes, and pennies. Find the minimum number of coins. Display the quantity of each coin and the total number of coins, similar to the example output below. Use global constant identifiers, of type unsigned int, for the values of quarters, nickels, dimes, and pennies. Example: const unsigned int QUARTER = 25: Do not use...
Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10 quarters, and 10 pennies. 2. Repeatedly prompt the user for a price in the form xX.xx, where X denotes a digit, or to enter q' to quit 3. When a price is entered a. If the price entered is negative, print an error message and start over requesting either a new price or to quit (indicated by entering a 'q)...
C++ HW Question Your program will simulate a simple change maker for a vending machine. It will start with a stock of coins and dollars. It will then repeatedly request the price for an item to be purchased or to quit. If given a price, it will accept nickels, dimes, quarters, one-dollar and five-dollar bills—deposited one at a time—in payment. When the user has deposited enough to cover the cost of the item, the program will calculate the coins to...
Write a C program that calculates exact change. In order to receive full credit, please remember that only int arithmetic is exact, so you’ll need to break up your double into two ints, the one before the decimal point and the one after the decimal point. Another point worth mentioning is that the % operator gives the remainder. In other words, when working with int values, 9 / 5 = 1 whereas 9 % 5 = 4. Keep this in...
PLease help!!! how to type them in Python !!!! Python help!! THank you so much Problem 1: (20 points) Optimal change You will write a program that uses the // and % operators to figure out how to give change for a specified amount using the minimum number of coins (quarters, dimes, nickels, cents). The good news is that our currency is specifically designed to make this problem easy. For a given number of cents, first use as many quarters...
in c code x Global Soccer 1.docx x Acceleration Due to 6 x M Inbox (5,949) - joshfor x M Inbox (4,224) - joshuar X ® AC ads/ACFrOgA6UB 1k4Z1i1xGLNQ1Lntj510 lutEUaA..pdf ECE 175: Computer Programming for Engineering Applications Lab Assignment #2 (Thursday sessions) Relevant Programming Concepts: • Branch Structure • Loop Problem 1 (15 points): Develop a C program that asks a user to enter a total change amount in cents) and outputs the change using the fewest coins. The coin...
I made this C program to count change and make a slip saying the exact dollar and change amount given. every time I run the program it says the change given is 477256577 and i'm not sure what I have done wrong? #include<stdio.h> int main(void) { char first, last; int pennies; int nickels; int dimes; int quarters; int loonies; int change; int t_dollars; int t_cents; printf("Type in your 2 initials and press return> "); scanf("%c%c",&first,&last); printf("%c%c please enter in your...
C++ Write a program that helps a young student learn to make change. Use the random number generator to generate change amounts between1¢ and 99¢. Ask the user how many quarters, dimes, nickels and pennies they need to make that amount. Determine whether the coins specified by the user total the specified amount and give them feedback on their answer including whether they used the minimum or optimum number of coins to produce the amount. Sample output of a program...
it c++ coding. please write on atom software. 1. Write a program that converts dollars into coins a. Request a dollar amount as an integer: $5.34 is input as 534 b. Use a constant variable to represent each coin as a fixed value: const int NICKEL 5; c. Use division and the mod function to calculate the number of each coin. Change Calculator Enter dollar amount (as an integer): $534 The equivalent in coins: 21 Quarters 0 Dimes 1 Nickels...