Question

In: Computer Science

Write a program for XXX Phones, a provider of cellular phone service. Prompt a user for...

Write a program for XXX Phones, a provider of cellular phone service. Prompt a user for maximum monthly values for talk minutes used, text messages sent, and gigabytes of data used, and then recommend the best plan for the customer’s needs. A customer who needs fewer than 400 minutes of talk and no text or data should accept Plan A at $29 per month. A customer who needs fewer than 400 minutes of talk and any text messages should accept Plan B at $35 per month. A customer who needs 400 or more minutes of talk and no data should accept either Plan C for up to 100 text messages at $45 per month or Plan D for 100 text messages or more at $50 per month. A customer who needs any data should accept Plan E for up to 2 gigabytes at $59 or Plan F for 2 gigabytes or more at $65. Save the file as CellPhoneService.java

Again, Don’t forget to create the application/project CellPhoneServiceTest.java Class that has the main method and an object to use the CellPhoneService class.

Solutions

Expert Solution

import java.util.Scanner;

public class CellPhoneService {
  
private static final int PLAN_A = 29;
private static final int PLAN_B = 35;
private static final int PLAN_C = 45;
private static final int PLAN_D = 50;
private static final int PLAN_E = 59;
private static final int PLAN_F = 65;
  
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char yesno;
  
do
{
System.out.print("Enter the maximum number of monthly call minutes required: ");
int callMinutes = Integer.parseInt(sc.nextLine().trim());
System.out.print("Enter the maximum number of monthly text messages required: ");
int textMessages = Integer.parseInt(sc.nextLine().trim());
System.out.print("Enter the maximum GB of data required: ");
int dataUsed = Integer.parseInt(sc.nextLine().trim());
suggestPlan(callMinutes, textMessages, dataUsed);
System.out.print("\nContinue? [y/n]: ");
yesno = sc.nextLine().trim().charAt(0);
if(yesno == 'N' || yesno == 'n')
break;
System.out.println();
}while(yesno != 'N' || yesno != 'n');
}
  
private static void suggestPlan(int call, int text, int data)
{
if(call < 400 && text == 0 && data == 0)
System.out.println("You can choose PLAN A at $" + PLAN_A);
else if(call < 400 && text > 0 && data == 0)
System.out.println("You can choose PLAN B at $" + PLAN_B);
else if(call >= 400 && text <= 100 && data == 0)
System.out.println("You can choose PLAN C at $" + PLAN_C);
else if(call >= 400 && text >= 100 && data == 0)
System.out.println("You can choose PLAN D at $" + PLAN_D);
else if(call >= 400 && text > 0 && data <= 2)
System.out.println("You can choose PLAN E at $" + PLAN_E);
else if(call >= 400 && text > 0 && data >= 2)
System.out.println("You can choose PLAN F at $" + PLAN_F);
}
}

********************************************************* SCREENSHOT *******************************************************


Related Solutions

A cellular phone service provider is offering a new calling plan that it claims will result...
A cellular phone service provider is offering a new calling plan that it claims will result in an average savings of more than 20% for its customers who switch to the plan. To evaluate this claim, a consumer watchdog organization contacted a random sample of this provider's customers who enrolled in the new plan and computed their individual savings (as a percentage of their original monthly bill). PctSavings(%) 9.84 14.13 15.01 23.47 19.07 21.37 19.64 22.38 26.56 22.52 23.11 18.77...
IN C This assignment is to write a program that will prompt the user to enter...
IN C This assignment is to write a program that will prompt the user to enter a character, e.g., a percent sign (%), and then the number of percent signs (%) they want on a line. Your program should first read a character from the keyboard, excluding whitespaces; and then print a message indicating that the number must be in the range 1 to 79 (including both ends) if the user enters a number outside of that range. Your program...
Using Java, write a program named MyAngles that will prompt the user for the measure of...
Using Java, write a program named MyAngles that will prompt the user for the measure of the three sides of a triangle and then reports the measurement of each interior angle of the triangle and the area of the triangle.
Create a program that creates and prints a random phone number using the following format: XXX-XXX-XXXX....
Create a program that creates and prints a random phone number using the following format: XXX-XXX-XXXX. Make sure your output include the dashes. Do not let the first three digits contain an 8 or 9 (HINT: do not be more restrictive than that) and make sure that the second set of three digits is not greater than 773. Helpful Hint: Think though the easiest way to construct the phone number. Each digit does do not have to be determined separately....
Write the correct regular expression pattern for a phone number field with the format XXX-XXX-XXXX
Write the correct regular expression pattern for a phone number field with the format XXX-XXX-XXXX
QUESTION THREE A cellular phone manufacturer situated in Kalabo district of western province (katondo cellular phones...
QUESTION THREE A cellular phone manufacturer situated in Kalabo district of western province (katondo cellular phones limited) produces three types of cellphones: Basic, Super and Delux. For the current year the company has a total of 10,000 direct labour hours and 7,500 machine hours available for production. Here below, are the sales and production parameters relating to the three types of cellphones: 4 Basic Super Delux Direct material @ K24/kg 0.75 kgs 0.625 kg 1.25 kg Direct labour @ k24...
Write a C program that loops and asks a user to enter a an alphanumeric phone...
Write a C program that loops and asks a user to enter a an alphanumeric phone number and converts it to a numeric one. No +1 at the beginning. You can put all code in one quiz1.c file or put all functions except main in phone.c and phone.h and include it in quiz1.c Submit your *.c and .h files or zipped project */ #pragma warning (disable: 4996) //windows #include <stdio.h> #include <string.h> #include <stdbool.h> #include <ctype.h> enum { MaxLine =...
Write a C program that prompt the user to enter 10 numbers andstores the numbers...
Write a C program that prompt the user to enter 10 numbers and stores the numbers in an array. Write a function, smallestIndex, that takes as parameters an int array and its size and return the index of the first occurrence of the smallest element in the array.The main function should print the smallest number and the index of the smallest number.
Write a C++ program that prompt the user to enter 10 numbers andstores the numbers...
Write a C++ program that prompt the user to enter 10 numbers and stores the numbers in an array. Write a function, smallestIndex, that takes as parameters an int array and its size and return the index of the first occurrence of the smallest element in the array.The main function should print the smallest number and the index of the smallest number.
Write a program to prompt the user to display the following menu: Sort             Matrix                   Q
Write a program to prompt the user to display the following menu: Sort             Matrix                   Quit If the user selects ‘S’ or ‘s’, then prompt the user to ask how many numbers you wish to read. Then based on that fill out the elements of one dimensional array with integer numbers. Then sort the numbers and print the original and sorted numbers in ascending order side by side. How many numbers: 6 Original numbers:                     Sorted numbers 34                                                                         2          55                                                      ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT