Results 1 to 3 of 3
  1. #1
    Gayethiri_86 is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Thumbs down New to JAVA and code cant compile

    Hi there,

    Ive been trying to figure out why my code dosent seem to be working.Ive been trying for a few hours now and it still would not compile.Can somebody please help me out with this thanks:)


    My code:

    public class CustMthBill
    {
    public static void main(String[]args)
    {
    String input; //To hold the users input
    char intPkg; //Internet package chosen by the customer

    //Create a Scanner object for keyboard input.
    Scanner keyboard = new Scanner(System.in);

    //Prompt the user for the internet package they want.
    System.out.println("Our internet service is offered in"+"three packages:");
    System.out.println("A,B,C.Which one do you want?");


    input = keyboard.nextLine();
    intPkg = input.charAT(0); [ERROR!!] Cannot find symbol-method charAT(int)

    //Display pricing for the selected package
    switch(intPkg )
    {
    case 'a':
    case 'A':
    System.out.println("$9.95 per month for 10 hrs of access.");
    break;

    case 'b':
    case 'B':
    System.out.println("$13.95 per month for 20 hrs of access.");
    break;

    case 'c':
    case 'C':
    System.out.println("$19.95 per month for unlimited access.");
    break;
    default:
    System.out.println("Invalid choice.");
    }
    }
    }

  2. #2
    Mattedatten is offline Member
    Join Date
    Aug 2009
    Location
    South Sweden
    Posts
    24
    Rep Power
    0

    Default

    Java Code:
    intPkg = input.charAT(0); [ERROR!!] Cannot find symbol-method charAT(int)
    input.CharAt, not input.charAT ^^

    This works:
    Java Code:
    intPkg = input.charAt(0); [ERROR!!] Cannot find symbol-method charAT(int)
    Altso, you forgot to import the scanner
    so, write
    Java Code:
    import java.util.Scanner;
    or
    Java Code:
    import java.util.*;
    at the top
    :)

  3. #3
    Gayethiri_86 is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

Similar Threads

  1. Code does not Compile
    By ustar in forum New To Java
    Replies: 13
    Last Post: 03-06-2010, 04:54 PM
  2. Code will not compile
    By ShotGunRockets in forum New To Java
    Replies: 17
    Last Post: 05-10-2009, 03:31 AM
  3. Replies: 6
    Last Post: 02-06-2009, 08:05 PM
  4. Compile/Execute code in Java app
    By Doctor Cactus in forum New To Java
    Replies: 5
    Last Post: 12-16-2008, 09:58 AM

Posting Permissions

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