Before I post this I just want to make clear that I just started coding like last week so i may seem a little slow.
Im currently having issues with an assignment regarding Internet Service provider billing. Ive tried several different sources but cannot seem to get an answer as to why im getting a initialization error. Im very very new to this stuff and its probably something basic that i just cant see. The assignment reads:
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.
The code i have so far is :
import java.util.Scanner; public class InternetBill { public static void main(String[] args) { //naming variables Scanner keyboard = new Scanner(System.in); int hoursUsed,regularHours,extraHours; double monthlyFee,extraHoursFee,totalFee; char packageLetter; System.out.println("Enter the type of internet you want(A,B,C)"); System.out.println("Enter the number of hours you used"); hoursUsed = keyboard.nextInt(); switch(packageLetter) //the calculations needed for result { ///////////////////////////////////////////////////////////// case 'A': monthlyFee = 9.95; regularHours = 10; extraHours = hoursUsed - regularHours; extraHoursFee = extraHours * 2.00; totalFee = monthlyFee + extraHoursFee; System.out.println("The total bill is $" + totalFee); break; ///////////////////////////////////////////////////////////// case 'B': monthlyFee = 13.95; regularHours = 20; extraHours = hoursUsed - regularHours; extraHoursFee = extraHours * 1.00; totalFee = monthlyFee + extraHoursFee; System.out.println("The total bill is " + totalFee); System.out.println("The total bill is $" +totalFee); break; ///////////////////////////////////////////////////////////// case 'C': totalFee = 19.95; System.out.println("The total bill is $" +totalFee + "."); break; default: System.out.println("Eenter A,B,C)"); } } }
The problem I have is that I do not know how to code right under
System.out.println("Enter the type of internet you want(A,B,C)");
I want to make it so that the user could enter either A B or C. I tired using "packageLetter=keyboard.nextChar();" but apparently you cant do that. Im so confused -_-.
I KNOW my code is good with the calculation part and the switch part but i dont know what to do from here