Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

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

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité  Chargement dans…3
×

## Consultez-les par la suite

1 sur 2 Publicité

# 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.\");
}
}
.

Publicité
Publicité

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

1. 1. 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."); }
2. 2. }