troubleshooting Question

Input integers from the keyboard

Avatar of Fred_45559
Fred_45559 asked on
Java
13 Comments2 Solutions534 ViewsLast Modified:
How do I write a program that inputs an integer from the keyboard representing the number of pennies, and prints how many dollars, quarters, dimes, nickels, and pennies it makes.


This is what I wrote and tested:

class Tester2
{
public static void main(String []args)
{
int number,x;
int cents = x;
int sum = x;
int digit;
Scanner input x=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");
      }

}


The program continues to give me  ";" expected on line 9.  Can you give me soon advice to make it work.





ASKER CERTIFIED SOLUTION
Mick Barry
Java Developer
Join our community to see this answer!
Unlock 2 Answers and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros