Results 1 to 3 of 3
- 03-05-2010, 06:24 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 4
- Rep Power
- 0
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.");
}
}
}
- 03-05-2010, 06:36 AM #2
Member
- Join Date
- Aug 2009
- Location
- South Sweden
- Posts
- 24
- Rep Power
- 0
input.CharAt, not input.charAT ^^Java Code:intPkg = input.charAT(0); [ERROR!!] Cannot find symbol-method charAT(int)
This works:
Altso, you forgot to import the scannerJava Code:intPkg = input.charAt(0); [ERROR!!] Cannot find symbol-method charAT(int)
so, write
orJava Code:import java.util.Scanner;
at the topJava Code:import java.util.*;
:)
- 03-05-2010, 06:43 AM #3
Member
- Join Date
- Mar 2010
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Code does not Compile
By ustar in forum New To JavaReplies: 13Last Post: 03-06-2010, 04:54 PM -
Code will not compile
By ShotGunRockets in forum New To JavaReplies: 17Last Post: 05-10-2009, 03:31 AM -
Running .java-files won't work/compile does!(Code inside)
By wyldstyle in forum New To JavaReplies: 6Last Post: 02-06-2009, 08:05 PM -
Compile/Execute code in Java app
By Doctor Cactus in forum New To JavaReplies: 5Last Post: 12-16-2008, 09:58 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks