Trying to get rid of error from my program.

Trying to find out what causing my errors?

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

}


errors-coins-2.JPG
waltbaby315Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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

Mick BarryJava DeveloperCommented:
> int cents = dollars, quarters, dimes, nickels, pennies;
> dollars = cents /100;

change that to:


cents = dollars, quarters, dimes, nickels, pennies;
int dollars = cents /100;
0
waltbaby315Author Commented:
This is error I got when I made the corrections
coinerror10.JPG
0
Mick BarryJava DeveloperCommented:

import java.util.*;

public class realcoins {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.println("Please type an integer for x");
		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");
	}

}

Open in new window

0

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.

Start your 7-day free trial
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.