write a program in java that determines the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and a dollar, in a 5-cent increments(25,30,35.....,90,95,or 100), and the machine accepts only a single dollar bill to pay for the item. for example a possible dialogue with the user might be "Enter price of item (from 25 cents to a dollar, in 5-cent increments):45 you boughtan item for 45 cents and gave me a dollar. so your change is 2 quarters, 0 dimes, and 1 nickles." include input checking. Display the change only if the valid price is entered (no less than 25 cents no more than 100 cents, and an integer multiple of 5 cents). otherwise display seperate error messages for any of the following invalid inputs: a cost under 25 cents, a cost that is not an integer multiple of 5, and a cost that is more than a dollar. Be sure to use the proper heading content and layout (heading.txt) Be sure to update the name, date, and documentation information. Calculations should be separate statements, not placed in the print
statement. The user will enter the cost of the item (integer) Validate the cost value and display any needed message according to the project instructions. The program will produce output similar to what is shown on page 132. Additional instruction: When the value of a coin denomination is zero, do not print the information for that coin. Using this at the base.
DOCUMENTATION Page ?, programming project #? This program ******************************************************************************/
import java.util.Scanner;
public class program##
{ public static void main(String[] args) { enter code here } }
The above question can be answered in the following steps-
STEP 1- First we will prompt the user to enter the price of the item under the conditions specified. Then check if the price input lies between 25 and 100 and is a multiple of 5.
STEP 2- if the above condition is specified, declare variables to store the no of quarters,dimes and nickles. Compute the change by deducting the price from 100. Then the change is converted to quarters, then the rest change is converted to dimes and the rest change into nickles.
STEP 3- Then we print the value of all denominations only if the value is NOT zero as mentioned in question.
STEP 4- And if the price does not lies in the VALID range, we check due to which reason did it get invalid and print the appropriate reason as given in question.
JAVA CODE-
//import the necessary package
import java.util.Scanner;
//define the class
public class program
{
//write the main method
public static void main(String[] args) {
//create a scanner Object
Scanner scn = new Scanner(System.in);
//prompt the user to enter the price of item
System.out.print("Enter price of
item (from 25 cents to a dollar, in 5-cent increments) : ");
int price = scn.nextInt(); //store
the price
//if price is valid,i.e,lies
between 25 to 100 and its divisble by 5, then its valid
if(price >=25 &&
price<=100 && (price%5) ==0){
//variable to store the number of
Quarters, dimes and Nickles
int noOfQuarters = 0, noOfDimes =
0, noOfNickles = 0;
//compute the change price by
reducing it from 100(a dollar)
int change = 100 - price;
//convert it to Quarters
if(change >= 25){
noOfQuarters = change/25;
change = change -
(noOfQuarters*25);
}
//convert the rest to Dimes
if(change >= 10){
noOfDimes = change/10;
change = change -
(noOfDimes*10);
}
//conver the rest to Nickles
if(change >= 5){
noOfNickles = change/5;
}
//print the change in terms of
Quarters,dimes and Nickles
//print only if value of a coin
denomination is NOT zero
System.out.print("Your change is =
");
if(noOfQuarters != 0){
System.out.print(noOfQuarters + "
Quarters ");
}
if(noOfDimes != 0){
System.out.print(noOfDimes + "
Dimes ");
}
if(noOfNickles != 0){
System.out.print(noOfNickles + "
Nickles");
}
}
//and otherwise, when the input
price is INVALID
else{
//check what is the reason and
print correct message
if(price <25){
System.out.println("A cost under 25
cents");
}
else if(price > 100){
System.out.println("A cost that is
more than a dollar");
}
else if((price%5) != 0){
System.out.println("A cost that is
not an integer multiple of 5");
}
}
}
}
IMAGE OF CODE-


OUTPUT-
Case #1

Case#2

If this answer helps, please give an up vote and feel free to comment for any query.
write a program in java that determines the change to be dispensed from a vending machine....
write a program in C that determines the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and a dollar, in a 5-cent increments(25,30,35.....,90,95,or 100), and the machine accepts only a single dollar bill to pay for the item. for example a possible dialogue with the user might be "Enter price of item (from 25 cents to a dollar, in 5-cent increments):45 you boughtan item for 45 cents and gave me...
Write the algorithm that determines the change to be dispensed from a vending machine. An item in the machine can cost between 5 cents and 1 dollar, in 5-cent increments (5,10,15,......90, 95, or 100), and the machine accepts only a single dollar bill to pay for the item. The user will provide the price and the program will output the price and calculate and output the total change and how many quarters, dimes and nickels need to be dispensed. DO...
Write a program in Java that simulates a vending machine: The vending machine sells three types of food: 1) Potato chips $1.25; 2) Cookies $0.85; 3) Candies $0.95. The program will prompt for the buyer to enter the amount in quarters (25 cents), dimes (10 cents), and nickels (5 cents). The program will then present a selection menu for the foods and prompt the buyer to enter the amount of quarters, dimes and nickels. The machine would then proceed to...
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 program that tells what coins to give out for as change from 1 cent to 99 cents. Use coin denominations of 25 cents (quarters), 10 cents (dimes), and 1 cent (pennies) only. Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. Solution Demo Hello I am the coin machine! I will give you the least number of coins for your change....
Vending Machine (Python 3) Thinking Outside the box Write a program that asks the user to enter a bill value (1 = $1 bill, 5 = $5 bill, etc.) and the price of an item they want to buy in pennies and calculate their change amount in dollars, quarters, dimes, nickels, and pennies. Your code should start like this: ## # This program simulates a vending machine that gives change # Define constants PENNIES PER DOLLAR = 100 PENNIES PER...
All items at a "Penny Fair" are priced less than $1.00. Write a program that makes change with a minimum number of coins when a customer pays for an item with a one dollar bill. Prompt for the item price in cents, report the change due, and the number of coins of each denomination required. Use only quarters, dimes, nickels, and pennies for change (no 50 cent pieces). See sample output but your program should work for any item price....
you are designing a matlab script that will function as an automated cash regisiter. the cash register will recive two inputs,the price of an item in cents, and the amount of cents payed by the customer. the cash register will then dispense change using the highest denominations of currency available ranging from 1 dollar bill to a penny dollar = 100 cents quarter =25 cents dime= 10 cents nickel=5 penny=1 cent your program should ensure that the highest available denomiation...
Please Walk me through this problem. Write a program that simulates the functionality of a vending machine having the following characteristics: The vending machine offers 5 products The vending machine accepts coins, 1 dollar bills, and 5 dollar bills The change is always given in coins, with maximum possible number of coins in each value: 25, 10, 5 or 1 cent. The selections available for user are numbers from 1 to 5. The user enters the money – simulate the...
(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...