Successfully reported this slideshow.
Your SlideShare is downloading. ×

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

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 2 Ad

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

Download to read offline

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

Advertisement
Advertisement

More Related Content

Similar to Write a class that calculates and displays the conversion of an entere.docx (20)

More from lez31palka (20)

Advertisement

Recently uploaded (20)

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. }

×