problem in simple program, new user
I am trying to make a basic program that lets a user input a number, then it will tell them what coins make up this number. This is a project for school and im almsot finished but keep running into an error with my "originalAmount" variable. I have been looking up whats wrong for the past hour with no success so ive decided to ask for help. Here is my code thus far, any help would be great, even a hint!
import java.util.Scanner;
public class coins
{
public static void main(String[] args)
{
int amount, orginalAmount,
quarters, dimes, nickels, pennies;
System.out.println("Enter a whole number from 1 to 99.");
System.out.println("This will tell you what coins make up your number");
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextInt();
quarters = amount / 25;
amount = amount % 25;
dimes = amount / 10;
amount = amount % 10;
nickels = amount / 5;
amount = amount % 5;
pennies = amount;
System.out.println(originalAmount +
" cents in coins can be given as:");
System.out.println(quarters + " quarters");
System.out.println(dimes + " dimes");
System.out.println(nickels + " nickels and");
System.out.println(pennies + " pennies");
}
}
Re: problem in simple program, new user
Do you ever define original amount? I see the statement:
int amount, originalAmount,...
but nowhere do I see you actually assign a value to originalAmount. You could fix this with a simple statement by assigning amount's value to originalAmount, but make sure this is before you do anything with amount.
Also note that you misspelled "originalAmount" in your declaration; you have it spelled "orginalAmount". :P
Hopefully this helps!
Re: problem in simple program, new user
ever have one of those days where your brain seems to not function, cant believe i misspelled that, thanks man!! solved...