Respuesta :
Answer:
Below!
Explanation:
This is the code I have. I am not sure what I am missing that it won't accept -
import java.util.Scanner;
class Dollars {
public static void main(String[] args) {
int numTwenties,numTens,numFives,numOnes,dollarAmount;
Scanner sc= new Scanner(System.in);
System.out.println("Please enter a dollar amount: ");
dollarAmount = sc.nextInt();
numTwenties = dollarAmount/20;
numTens = (dollarAmount - 20*numTwenties)/10;
numFives = (dollarAmount - (10*numTens + 20*numTwenties))/5;
numOnes = (dollarAmount - (10*numTens + 20*numTwenties + 5*numFives));
System.out.println(+ dollarAmount + " converted is" + numTwenties + " $20s, " + numTens + " $10s, " + numFives + " $5s, and " + numOnes + " $1s.");
}
}
This is what it is giving me -
Test CaseIncomplete
Dollars 598
Input598
OutputPlease enter a dollar amount: 598
598 converted is29 $20s, 1 $10s, 1 $5s, and 3 $1s.
Results
$598 converted is 29 $20s, 1 $10s, 1 $5s, and 3 $1s
Expected Output
$598 converted is 29 $20s, 1 $10s, 1 $5s, and 3 $1s
It's mainly the price measure with one currency against the other, even as rate changes, money through one country can get relatively weak or powerful in comparison with the other currencies, and the further program can be defined as follows:
Program Explanation:
- Import package.
- Defining a class Conversion .
- Defining an integer variable "twenties, tens, fives, ones, amount, n".
- After defining a variable, a Scanner class object is declared that inputs value in it.
- In the next step, a conditional statement is declared that checks value and hold its calcuated value.
- At the last, a print method is declared that prints its value.
Program:
import java.util.*;//import package
public class Conversion //defining a class Conversion
{
public static void main(String ar[])//defining a main method
{
int twenties, tens, fives, ones, amount, n;//defining an integer variable
Scanner obcdf= new Scanner(System.in);//creating Scanner class object to input value
System.out.println("Enter amount: ");//print message
amount = obcdf.nextInt(); //input integer value
n = amount; //holding innput value
if(amount > 20)//using if block that check amount value greater than 20
{
twenties = (int)(amount/20); //using twenties that divides amount value by 20 and hold its integer value
amount = amount % 20;// holding modules value in amount variable
}
else //defining else block
{
twenties = 0;//holding 0 in twenties variable
}
if(amount > 10)//using if that check amount value greater than 10
{
tens = (int)(amount/10);//using tens that divides amount value by 10 and hold its integer value
amount = amount % 10;// holding modules value in amount variable
}
else //defining else block
{
tens = 0;//holding 0 in tens variable
}
if(amount > 5)//using if that check amount value greater than 5
{
fives = (int)(amount/5);//using tens that divides amount value by 5 and hold its integer value
amount = amount % 5;// holding modules value in amount variable
}
else //defining else block
{
fives = 0;//holding 0 in fives variable
}
if(amount > 1)//using if that check amount value greater than 1
{
ones = (int) amount;//holding amount value in ones variable
}
else //defining else block
{
ones = 0;//holding 0 in ones variable
}
System.out.println("$"+n+" converted is "+twenties+" $20s, "+tens+" $10s, "+fives+" $5s, and "+ones+" $1s."); //print value
}
}
Output:
Please find the attached file.
Learn more:
brainly.com/question/4448370