# how can I get an output value of equal amount.

How get a different value in the output? Example I input  integer of 100 pennies an get a dollar, but zero for the quarters pennie, dimes, nickels. How can I get an equal value for all. Example quarters 4, dimes 10, nickels 20, pennies 100.

import java.util.*;
public class realcoins
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("type an interger in pennies");
int cents = input.nextInt();
int dollars = cents / 100;
int remaining = cents % 100;
int quarters = remaining / 25;
remaining = remaining % 25;
int dimes = remaining / 10;
remaining = remaining % 10;
int nickels = remaining / 5;
int pennies = remaining % 5;
System.out.println(cents + " cents is=");
System.out.println(dollars + " dollars " + quarters + "quarters"+ dimes + "dimes" + nickels + "nickels" + "and" + pennies + "pennies");
}

}
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:

int remaining = cents % 100;

remaiing is 100(modulo 100) = 0
then you divied remaiang by any number - becomes 0 all the time of course
Commented:
int dollars = cents / 100;

int quarters = cents/25;

int dimes = cents/10;

int nickels = cents/5;

then you'll have different values
Commented:
and

int pennies = cents/100;

(not ddivied by 5 as you have)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Is there any way I can change it so  they all will be equal
Commented:
You mean you want equal values in the result string? equal number of quarters, dimes, etc. ?
Commented:
if you start from input value:

100 + 25 + 10 + 5 + 1 = 141

and
indeed use remaining then you'll get reasonable
program:

``````import java.util.*;
public class realcoins
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("type an interger in pennies");
int cents = input.nextInt();
int dollars = cents / 100;
int remaining = cents - dollars*100;
int quarters = remaining/25;
remaining = remaining - 25*quarters;
int dimes = remainig/10;
remnaming = remaninig-10*dimes;
and so on...

System.out.println(cents + " cents is=");
System.out.println(dollars + " dollars " + quarters + "quarters"+ dimes + "dimes" + nickels + "nickels" + "and" + pennies + "pennies");
}

}
``````

###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.