# How do you do in an input and then get an output?

• 01-26-2013, 09:24 PM
coding
How do you do in an input and then get an output?
How do you make it so it ask you how much money you have used, and the amount of money you have left and it subtracts it and tells you how much you have left in bills?

Lets say you used \$20.26 , and you originally had 40 dollars you put 20.26 as the amount you spent and then you put 40 as the original amount and it outputs it as the answer as 19.74 dollars and then it breaks it down further and tells you you have 19 dollars 2 quarters 2 dimes and 4 pennies?

I'm have a hard time figuring out how to code that
• 01-27-2013, 01:57 AM
Fubarable
Re: How do you do in an input and then get an output?
• 01-27-2013, 02:41 AM
coding
Re: How do you do in an input and then get an output?
I've done this
Quote:

public class s {
public static void main(String[] args)
{
int a ;
int b ;
int sub;
@SuppressWarnings("resource")
Scanner input = new Scanner(System.in);
a=input.nextInt(); // store the input a.
b=input.nextInt(); // store the input in b.

sub = a - b; //subtract the 2 two numbers

System.out.println("Your change is : " + sub); // display the result of the two numbers

}
}
And when I enter normal numbers its fine, but when i enter decimals like 10.5 i get an error and idk how it can break up the answers in dollars, quartiers, dimes and pennies.