Question
Use Fill IN the OUTLINE BELOW: Program Goal The goal of this program is to make change. Generate a random Price between 0 and 1000.
Use Fill IN the OUTLINE BELOW:
Program Goal The goal of this program is to make change.
Attached is a program template, Main.java. Modify and submit this file to GradeScope. DO NOT CHANGE THE NAME. If you are using an IDE which requires package headers, remove them before uploading to GradeScope. No D2L Submission is required! The only thing you will be graded on is your GradeScope Submission! Example
Colour Key:
AutoGrader Assumptions General
Output Format General For parsing purposes the autograder assumes that the only decimal points (periods), dollar signs, and numbers in a line correspond to the value. For Example, the line "1. Number of $s: 9" will be interpreted as "1.$9", and throw an error. Please keep this in mind when generating your output. Consider instead, "Dollars: 9", or "The number of Dollars needed to make the change is: 9" which are both interpreted as "9". Note: "9.0" does not equal "9" Line by Line Breakdown
Input Format
Useful Libraries, Methods, and Links
|
OUTLINE :
// IMPORT ANY CLASSES YOU NEED HERE
public class Main { public static void main(String[] args) { double price = 0.0; // Place Holder Value /* TODO 1 GENERATE RANDOM PRICE * Condition: The random number must be greater than 0 */ // TODO 2 Print out your random price with a Dollar Sign and Rounded 2 Decimal Places System.out.println(price); // Place Holder Print Statement may need updated to format the number correctly
// TODO 3 Read in Double Value from Keyboard As Payment // Prompt System.out.println("Please enter your payment: "); double payment = 0.0; // Place Holder Value
// TODO 4 Calculate the TOTAL change amount double change = 0.0; // Place Holder Value // TODO 5 Print Out the Change Value formatted with a Dollar Sign and Rounded 2 Decimal Places
System.out.println(change); // Place Holder Print Statement may need updated to format the number correctly
//NOTICE THESE ARE INTs THEY SHOULD CONTAIN WHOLE NUMBERS ONLY int dollars = 0, quarters = 0, dimes = 0, nickels = 0, pennies = 0; // Place Holder Values
// Hint: Consider Multiplying away the Decimal Place in Change to use whole number modulus // Consider Rounding after multiplying to mitigate inaccuracies introduced by the double datatype // TODO 6 Calculate the Number of Dollars Needed to Make the Change // TODO 7 Calculate the Number of Quarters Needed to Make the Change // TODO 8 Calculate the Number of Dimes Needed to Make the Change // TODO 9 Calculate the Number of Nickels Needed to Make the Change // TODO 10 Calculate the Number of Pennies Needed to Make the Change
// Dollars System.out.println(dollars); // Quarters System.out.println(quarters);
//Dimes System.out.println(dimes);
// Nickels System.out.println(nickels);
// Pennies System.out.println(pennies);
}
}
Step 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