MINDTAP Frum Cengage Search this course A Programming Exercise 5-4 Instructions
ID: 3748888 • Letter: M
Question
MINDTAP Frum Cengage Search this course A Programming Exercise 5-4 Instructions CellPhoneServi.+ 1 import java.util.*; 2 public class CelLPhoneService 3 public static void main (String args]) Write a program for Horizon Phones, a Ll provider of cellular phone service. Prompta // Write your code here user for maximum monthly values for talk minutes used, text messages sent, and gigabytes of data used, and thern recommend the best plan for the customer's needs. . A customer who needs fewer than 500 minutes of talk and no text or data should accept Plan A at $49 per month. .A customer who needs fewer than 500 minutes of talk and any text messages should accept Plan B at $55 per month. .A customer who needs 500 or more minutes of talk and no data should accept either Plan C for up to 100 text messages at $61 per month or Plan D for 100 text messages or more at $70 per month. .A customer who needs any data should accept Plan E for up to 3 gigabytes at $79 or Plan Ffor 3 gigabytes or more at $87 GradingExplanation / Answer
Java code or program for the given requirement:
import java.util.*;
public class CellPhoneService {
public static void main(String[]args) {
//Scanner class object to read inputs
Scanner scan = new Scanner(System.in);
//prompting user to input values
System.out.println(" **Kindly input values for monthly plan** ");
System.out.print("Minutes of talk?");
int mins=scan.nextInt();
System.out.println("Would you like to send text messages?(Yes or No)");
String txt=scan.next();
boolean hasMsg=false;
if("YES".equalsIgnoreCase(txt))
{
hasMsg=true;
}
int txtMsgLimit = 0,dataLimit=0;
if(hasMsg)
{
System.out.println("How many text messages?");
txtMsgLimit=scan.nextInt();
}
System.out.println("Would like to use data?(Yes or No)");
String data=scan.next();
boolean hasData=false;
if("YES".equalsIgnoreCase(data))
{
hasData=true;
}
if(hasData)
{
System.out.println("How much data?(Provide data in GB's)");
dataLimit=scan.nextInt();
}
/* All conditions STARTS */
if(mins < 500 ) //if minutes < 500, the apply other conditions
{
if(hasMsg)
{
System.out.println("Recommandations for you:");
System.out.println(" Plan: Plan B");
System.out.println(" Cost: $55 per month");
}else if(hasMsg==false && hasData== false)
{
System.out.println("Recommandations for you:");
System.out.println(" Plan: Plan A");
System.out.println(" Cost: $49 per month");
}else if(hasData)
{
if(dataLimit<3)
{
System.out.println("Recommandations for you:");
System.out.println(" Plan: Plan E");
System.out.println(" Cost: $79 per month");
}else if(dataLimit >=3)
{
System.out.println("Recommandations for you:");
System.out.println(" Plan: Plan F");
System.out.println(" Cost: $87 per month");
}
}
}else if(mins >=500) //if minutes>=500, the apply other conditions
{
if(hasData==false && txtMsgLimit <100 )
{
System.out.println("Recommandations for you:");
System.out.println(" Plan: Plan C");
System.out.println(" Cost: $61 per month");
}else if(hasData==false && txtMsgLimit >=100 )
{
System.out.println("Recommandations for you:");
System.out.println(" Plan: Plan D");
System.out.println(" Cost: $70 per month");
}else if(hasData)
{
if(dataLimit<3)
{
System.out.println("Recommandations for you:");
System.out.println(" Plan: Plan E");
System.out.println(" Cost: $79 per month");
}else if(dataLimit >=3)
{
System.out.println("Recommandations for you:");
System.out.println(" Plan: Plan F");
System.out.println(" Cost: $87 per month");
}
}
}/* All conditions END */
}
}
Output:
**Kindly input values for monthly plan**
Minutes of talk?580
Would you like to send text messages?(Yes or No)
no
Would like to use data?(Yes or No)
yes
How much data?(Provide data in GB's)
4
Recommandations for you:
Plan: Plan F
Cost: $87 per month
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.