Successfully reported this slideshow.

Write a class that calculates and displays the conversion of an entere.docx

Write a class that calculates and displays the conversion of an entered number of dollars into currency denominations-20s, 10s, 5s, and 1s. Save the class as Dollars.java.
Solution
import java.util.Scanner;
public class Dollars
{
public static void main(String [] args)
{
Scanner keyboard=new Scanner(System.in);
Systen.out.println(\" Enter the amount in dollars:\");
int DollarAmount = keyboard.nextInt();
int numTwenties = totalAmount/20;
int numTens = (totalAmount - 20*numTwenties)/10;
int numFives = (totalAmount - (10*numTens + 20*numTwenties))/5;
int numOnes = (totalAmount - (10*numTens + 20*numTwenties + 5*numFives))/1;
System.out.println(\"You have entered \$ \" + totalAmount );
System.out.println(\" The result is \" + numTwenties + \" twenties, \" + numTens + \" tens, \" + numFives + \" fives, \"Â Â Â Â  numOnes + \" ones.\");
}
}
.

Write a class that calculates and displays the conversion of an entered number of dollars into currency denominations-20s, 10s, 5s, and 1s. Save the class as Dollars.java.
Solution
import java.util.Scanner;
public class Dollars
{
public static void main(String [] args)
{
Scanner keyboard=new Scanner(System.in);
Systen.out.println(\" Enter the amount in dollars:\");
int DollarAmount = keyboard.nextInt();
int numTwenties = totalAmount/20;
int numTens = (totalAmount - 20*numTwenties)/10;
int numFives = (totalAmount - (10*numTens + 20*numTwenties))/5;
int numOnes = (totalAmount - (10*numTens + 20*numTwenties + 5*numFives))/1;
System.out.println(\"You have entered \$ \" + totalAmount );
System.out.println(\" The result is \" + numTwenties + \" twenties, \" + numTens + \" tens, \" + numFives + \" fives, \"Â Â Â Â  numOnes + \" ones.\");
}
}
.