Results 1 to 3 of 3
  1. #1
    saba2005 is offline Member
    Join Date
    Sep 2011
    Posts
    1
    Rep Power
    0

    Default 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");
    }
    }
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

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

  3. #3
    Aero is offline Member
    Join Date
    Sep 2011
    Posts
    14
    Rep Power
    0

    Default Re: I was wondering if why Im getting a cant find symbol error can someone please hel

    Scanner sc = new Scanner(System.in);

    That's how you use the Scanner.

Similar Threads

  1. Cannot Find Symbol Error
    By javadummy1 in forum New To Java
    Replies: 6
    Last Post: 04-09-2011, 10:13 AM
  2. Please help- Error: cannot find symbol
    By Avthar in forum New To Java
    Replies: 4
    Last Post: 02-28-2011, 07:34 AM
  3. Cannot find symbol Error
    By new_Java in forum New To Java
    Replies: 3
    Last Post: 02-17-2011, 11:23 PM
  4. Cannot find symbol error
    By rajivjoshi in forum New To Java
    Replies: 3
    Last Post: 05-31-2010, 10:13 AM
  5. Replies: 9
    Last Post: 10-18-2008, 08:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •