Create a java program from detailed directions: Create appropriate variables for
ID: 673029 • Letter: C
Question
Create a java program from detailed directions:
Create appropriate variables for the data.
Follow established programming conventions for writing java programs
Able to write a nested if or switch statement
Able to input data from the user
Use the print statement for output
Write a program for Horizon 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 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 2 gigabytes at $79 or Plan F for 2 gigabytes or more at $87. Save the file as CellPhoneService.java.
Explanation / Answer
import java.util.*;
class Phone{
public static void main(String args[]){
int talk,sms,gb;
Scanner in = new Scanner(System.in);
system.out.println("Enter number of minutes:");
talk = in.nextInt();
system.out.println("Enter number of text sms:");
sms = in.nextInt();
system.out.println("Enter number of gb of data used:");
gb = in.nextInt();
if(talk < 500 && sms == 0)
System.out.println("Plan A $49 per month");
else if(talk < 500 && sms > 0)
System.out.println("Plan B $55 per month");
else if(talk >= 500 && gb == 0){
if(sms <= 100)
System.out.println("Plan C $61 per month");
else
System.out.println("Plan D $70 per month");
}
else if(gb > 0 && gb < 2)
System.out.println("Plan E $79 per month");
else if(gb > 2)
System.out.println("Plan F $87 per month");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.