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?
 
objectsCommented:

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
 
objectsCommented:
> 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.