Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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(); }

} image text in transcribed

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 50

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 1 Lnai 9851

Authors: Paolo Frasconi ,Niels Landwehr ,Giuseppe Manco ,Jilles Vreeken

1st Edition

3319461273, 978-3319461274

More Books

Students also viewed these Databases questions