Question
Having an issue with this java program. The validator for the letter inputted causes an infinite loop. The question for the program will be posted
Having an issue with this java program. The validator for the letter inputted causes an infinite loop. The question for the program will be posted below the code. Thank you for any help provided.
/* * This program calculates a customers monthly bill */ package hw3;
import java.util.Scanner; public class dataplan {
public static void main(String[] args) { // Define variables int GBs, Holder; double Bill; String Plan = " "; Scanner input = new Scanner(System.in); System.out.println("Enter what data plan you have (A, B, or C): "); Plan = input.next(); do { System.out.println("You did not enter a valid data plan try again"); System.out.println("Enter what data plan you have (A, B, or C): "); Plan = input.next(); }while (Plan != "A" || Plan != "B" || Plan != "C"); System.out.println("Enter how many GBs of data you used (Between 1 and 50): "); GBs = input.nextInt(); do { System.out.println("You did not enter a valid amount of GBs"); System.out.println("Enter how many GBs of data you used (Between 1 and 50): "); GBs = input.nextInt(); }while (GBs 50); if (Plan == "A") { Holder = (GBs - 2); Bill = (((Holder) * 10) + 29.99); System.out.println("Your bill this month is $"+Bill); } else if ( Plan == "B") { Holder = (GBs - 4); Bill = (((Holder) * 5) + 39.99); System.out.println("Your bill this month is $"+Bill); } else { Bill = 49.99; System.out.println("Your bill this month is $"+Bill); } if (GBs
input.close(); }
}
Wireless Service Provider) A Wireless service provider has three different packages for its customers: Package A: For $29.99 per month 2GB of data is provided. Additional data is $10.00 Package B: For $39.99 per month 4GB of data is provided. Additional data is $5.00 Package C: For $49.99 per month unlimited data is provided. per GB per GB Write a program that calculates a customer's monthly bill. It should ask which package the customer has purchased and how many GB of data was used. It should then display the total amount due. The program should recommend which package is the best for the customer Input Validation: Be sure the user only select package A, B or C. Also the GB used has to be between 0 and 50Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started