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.
I need the CellPhoneServiceTest.java to have the main method and all the objects in the CellPhoneService.java. The CellPhoneServiceTest.java should call the information from CellPhoneService.java with CellPhoneService c = new CellPhoneService();
Code is Given Below:
=========================
CellPhoneService.java
============================
public class CellPhoneService {
//declaring variable to hold minutes,messages and
data
int minutes;
double data;
int message;
//this method will find best plan to print
details
public void getBestPlan() {
//checking for best plan
if(minutes<400 &&
data==0 && message==0) {
System.out.println("Best Plan For you is A at $29 only");
return;
}
if(minutes<400 &&
message>0 && data==0) {
System.out.println("Best Plan For you is B at $35 only");
return;
}
if(minutes>=400 &&
message<=100 && data==0) {
System.out.println("Best Plan For you is C at $45 only");
return;
}
if(minutes>=400 &&
message>100 && data==0) {
System.out.println("Best Plan For you is D at $50 only");
return;
}
if(data<=2) {
System.out.println("Best Plan For you is E at $59 only");
return;
}
if(data>2) {
System.out.println("Best Plan For you is F at $65 only");
return;
}
}
}
CellPhoneServiceTest.java
===========================
import java.util.Scanner;
public class CellPhoneServiceTest {
public static void main(String[] args) {
//creating scanner object to get
data from user
Scanner scn=new
Scanner(System.in);
//asking user to enter data
System.out.print("Enter maximum
monthly values for talk minutes used: ");
int minutes=scn.nextInt();
System.out.print("Enter maximum
monthly values for text messages sent: ");
int message=scn.nextInt();
System.out.print("Enter maximum
monthly values for gigabytes of data used: ");
double data=scn.nextDouble();
//creating cell phone service
object
CellPhoneService c=new
CellPhoneService();
//setting data to object
c.minutes=minutes;
c.message=message;
c.data=data;
//calling getBestPlan method
c.getBestPlan();
}
}
Output:
==============
Code Snapshot:
=============
Get Answers For Free
Most questions answered within 1 hours.