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...
Write a program that calculates the salary of employees. The program should prompt the user to...
Write a program that calculates the salary of employees. The program should prompt the user to enter hourly rate and number of hours of work a day. Then, the program should display the salary daily, bi-weekly (5 days a week), and monthly. Sample program: Enter your hourly rate: >>> 20 Enter how many hours you work a day: >>> 8 Your daily salary is: $160 Your bi-weekly salary is: $1600 Your monthly: $3200
Write a C program Your program will prompt the user to enter a value for the...
Write a C program Your program will prompt the user to enter a value for the amount of expenses on the credit card. Retrieve the user input using fgets()/sscanf() and save the input value in a variable. The value should be read as type double. The user may or may not enter cents as part of the input. In other words, expect the user to enter values such as 500, 500.00 and 500.10. The program will then prompt the user...
write a program to perform the following in C Your program should prompt the user to...
write a program to perform the following in C Your program should prompt the user to enter ten words, one at a time, which are to be stored in an array of strings. After all of the words have been entered, the list is to be reordered as necessary to place the words into alphabetical order, regardless of case. Once the list is in alphabetical order, the list should be output to the console in order. The program should execute...
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.
1. Write a program in C++ to find the factorial of a number. Prompt the user...
1. Write a program in C++ to find the factorial of a number. Prompt the user for a number and compute the factorial by using the following expression. Use for loops to write your solution code. Factorial of n = n! = 1×2×3×...×n; where n is the user input. Sample Output: Find the factorial of a number: ------------------------------------ Input a number to find the factorial: 5 The factorial of the given number is: 120 2. Code problem 1 using While...
Write a program that will input the information for 2 different employees. Prompt the user for...
Write a program that will input the information for 2 different employees. Prompt the user for the first employee’s name, hours worked and rate. Compute the salary and display it. Do the same for the second and third employees. Then, display a message to the effect that the highest salary is whatever and the lowest salary is whatever. When the program runs, the following should display information should line up just as I have it below. E:\> java Quiz4 Name:...
Write a C++ Program. Include the Homework header. Then prompt the user for a temperature that...
Write a C++ Program. Include the Homework header. Then prompt the user for a temperature that is in Fahrenheit for some water. Input the temperature (either an int or a double).   then output one of three statements: if the temperature is below 32 degrees or below tell them it is ice. For example if they input 22 then the output would be: At a temperature of 22 degrees the water would take the form of ice. if the temperature is...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT