internet service provider java coding

Internet Service Provider
An Internet service provider has three different subscription packages for its customers:
Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.
Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month unlimited access is provided.
Write a program that calculates a customer’s monthly bill. It should ask the user to enter the letter of the package the customer has purchased *A, B, or C) and the number of hours that were used. It should then display the total charges.


I started off with only package A to see if it would work, but it doesn't and I am getting a lot of error messages that I don't understand. What am I doing wrong with this first part?


import java.util.Scanner;

public class InternetPackages

{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
      char packageLetter=0;
      int totalHours, regularHours, additionalHours=0;
      double monthlyFee, additionalHoursFee=0, totalFee; 
           
      
      System.out.println("Enter the letter of package purchased (either A, B, or C.");
      System.out.println("Enter the number of hours used"); 
      totalHours = input.nextInt();
      
      
      switch (packageLetter)
      
      
      {
      case 'A':
      case 'a':
      monthlyFee = 9.95;
      regularHours = 10;
      additionalHoursFee = additionalHours * 2.00;
      totalFee = monthlyFee + additionalHoursFee;
      System.out.print ("The total charges is $" + totalFee + ".");
      break; 

Open in new window

drunk0ffhateAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
What error messages are you receiving?
0
drunk0ffhateAuthor Commented:
Exception in thread "main" java.util.InputMismatchException
	at java.util.Scanner.throwFor(Scanner.java:909)
	at java.util.Scanner.next(Scanner.java:1530)
	at java.util.Scanner.nextInt(Scanner.java:2160)
	at java.util.Scanner.nextInt(Scanner.java:2119)
	at InternetPackages.main(InternetPackages.java:19)

Open in new window


After compiling everything it says operation complete, but when I enter the values it gives me those error messages.
0
käµfm³d 👽Commented:
Look at lines 4 - 6. Your first prompt asks for a letter, but then it never gets input from the user. It just prints out the next prompt which asks for a number. If you are entering a letter in response to the first prompt, then the first line of code that expects input from the user (line 6) is looking for an integer, not a letter. Add in a line that will accept the input of a letter from the user.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

drunk0ffhateAuthor Commented:
Scanner input = new Scanner(System.in);
      char packageLetter=0;
      int totalHours, regularHours, additionalHours=0;
      double monthlyFee, additionalHoursFee=0, totalFee; 
      String inputString;
           
      
      System.out.println("Enter the letter of package purchased (either A, B, or C.");
      packageLetter = inputString.charAt(0);
      System.out.println("Enter the number of hours used"); 
      totalHours = input.nextInt();

Open in new window




Like this? I changed it but now it says that inputString.charAt(0);   hasnt been initialized
0
käµfm³d 👽Commented:
How do you get input from the user? (Hint, you're doing it in line 11 of your last post.) Look at the documentation for the Scanner class and determine which method would be appropriate to receive a letter as input.
0
drunk0ffhateAuthor Commented:
Oh ok, so this is it?

System.out.println("Enter the letter of package purchased (either A, B, or C.");
      packageLetter = input.nextChar();

Open in new window


It cannot find that symbol though so how would I add that into my coding?
0
käµfm³d 👽Commented:
It cannot find that symbol though...
You mean that the IDE does not recognize the nextChar method? If so, what version of Java are you using?
0
krakatoaCommented:
The Scanner class does not have a method "nextChar()".
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:
So I take it that none of my input was helpful?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.