Results 1 to 3 of 3
- 09-24-2011, 11:34 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 1
- Rep Power
- 0
I was wondering if why Im getting a cant find symbol error can someone please help
import java.util.Scanner;
class ExactChange{
public static void main(String[] args) {
// Declare a data type Scanner
Scanner scan = Scanner (System.in);
final int DOLLAR = 100; // One dollar in cents
final int QUARTER = 25; // One quarter in cents
final int DIME = 10; // One dime in cents
final int NICKEL = 5; // One nickel in cents
final int Penny = 1; //
int value;
// Integer value read from input
System.out.println("Input the purchase amount [0-100]: ");
value = scan.nextInt();
System.out.println ("Input amount paid");
value = scan.nextInt();
// Report error if invalid integer is entered.
System.out.print ("Invalid purchase amount. ");
System.out.println ("Must be between 0 and 100.");
// Report error if invalid integer is entered.
if (value<0 || value>DOLLAR) {
System.out.print ("Invalid purchase amount. ");
System.out.println ("Must be between 0 and 100.");
}
// Subtract the purchase amount from 1 dollar, and determine
// the number of quarters, dimes, nickels, and pennies that
// this change amount can be divided into.
else {
// Amount of change that would be received from one dollar
int change = DOLLAR - value;
int num_quarter=0; // Counts number of quarters
int num_dime=0; // Counts number of dimes
int num_nickel=0; // Counts number of nickels
int num_penny=0; // Counts number of pennies
// Use integer division to determine how many quarters, and
// then use mod operation to determine the remaining change.
// Repeat for dimes, nickels, and pennies.
num_quarter = change / QUARTER;
change = change % QUARTER;
num_dime = change / DIME;
change = change % DIME;
num_nickel = change / NICKEL;
change = change % NICKEL;
num_penny = change;
// Report change to standard out.
if (DOLLAR-value == 1)
System.out.println ("Your change of "+(DOLLAR-value)+
" cent is given as:");
else
System.out.println ("Your change of "+(DOLLAR-value)+
" cents is given as:");
if (num_quarter == 1)
System.out.println (" "+num_quarter+" Quarter");
else
System.out.println (" "+num_quarter+" Quarters");
if (num_dime == 1)
System.out.println (" "+num_dime+" Dime");
else
System.out.println (" "+num_dime+" Dimes");
if (num_nickel == 1)
System.out.println (" "+num_nickel+" Nickel");
else
System.out.println (" "+num_nickel+" Nickels");
if (num_penny == 1)
System.out.println (" "+num_penny+" Penny");
else
System.out.println (" "+num_penny+" Pennies");
}
}
}
-
Re: I was wondering if why Im getting a cant find symbol error can someone please hel
You might want to tell us which line is causing the error and show the entire error message.
- 09-25-2011, 02:48 AM #3
Member
- Join Date
- Sep 2011
- Posts
- 14
- Rep Power
- 0
Similar Threads
-
Cannot Find Symbol Error
By javadummy1 in forum New To JavaReplies: 6Last Post: 04-09-2011, 10:13 AM -
Please help- Error: cannot find symbol
By Avthar in forum New To JavaReplies: 4Last Post: 02-28-2011, 07:34 AM -
Cannot find symbol Error
By new_Java in forum New To JavaReplies: 3Last Post: 02-17-2011, 11:23 PM -
Cannot find symbol error
By rajivjoshi in forum New To JavaReplies: 3Last Post: 05-31-2010, 10:13 AM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks