The problem is quite simple, the numeral value to the left of decimal point will be the number of dollars. And we have to then find the rest of the components from the remaining part. So in order to do this we first multiply the value with 100.
amt = Entered_value*100;
Dollars = amt/100;
amt = amt %100;
Now to find quaters we will divide amt by 25.
quaters = amt/25;
amt = amt%25
and so on..
Please find this link for pastebin :- http://pastebin.com/JUd8K0h5
Please find the code below:-
import java.util.*;
import java.lang.*;
import java.io.*;
class CalculateChanges
{
public static void printChanges(double amt) {
int tot = (int)(amt *100);
int dollars = tot / 100;
tot = tot%100;
int quarters = tot/25;
tot = tot%25;
int dimes = tot/10;
tot = tot%10;
int nickles = tot/5;
int pennies = tot%5;
System.out.println("Dollars : " + dollars);
System.out.println("Quarters : " + quarters);
System.out.println("Dimess : " + dimes);
System.out.println("Nicles : " + nickles);
System.out.println("Pennies : "+ pennies);
}
public static void main (String[] args) throws
java.lang.Exception
{
Scanner inp = new Scanner(System.in);
double amt = inp.nextDouble();
printChanges(amt);
}
}
How do I type 2.18 into java? We have to make up a scenario and put...
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...
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)...
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...