Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Any help would be appreciated (Java). An upstart cell phone service provider wou

ID: 3703490 • Letter: A

Question

Any help would be appreciated (Java).

An upstart cell phone service provider would like you to write a program to generate cell phone bills.

The company offers single plans and family plans, with the following rates:
Single plan: $29.99 for the one line
Family plan: $49.99 total for the first two lines
Additional $22.00 for the third line
Additional $12.00 for each additional line after that
These monthly rates include unlimited talk and text, and 2 GB of data per phone line.
Both plans charge $8.49 per GB for data overages.

Implementation Requirements
The program will be written in NetBeans.
? Create a new project named: Topic8project

? with a main class name of: CellPhoneBillGenerator

Within your program code, you must:
? Include complete program description and author in the top of file comments

? Include comments above each defined method, including a method description and @param and
@return tags for parameters and return values.

? Define and use constants for ALL fixed prices and the included GB per line (so there should be
no hardcoded values in the program calculations).
o Instead of defining all constants in the main method, each constant should be defined
within the method that uses it
From the main method:

? First display one line program description to the user.

? Then prompt for and read the following inputs from the user:
o Customer’s plan type character: S for single plan or F for family plan, accepting both
upper and lowercase letters. Tell the user how to enter the answer in the prompt.

o Data usage: The number of GBs of data used by the customer in the past month (floating
point value, not whole numbers).

o Number of lines:
? For single plans, only 1 line is allowed, and no further input will be necessary
? For family plans, must read this input.
A minimum of 2 lines will be on the plan, even if the user enters a lower number.
The program should adjust the value for the number of lines, as necessary.

? After reading the necessary inputs from the user, call the four methods described below.
When the called method returns a value, be sure to store the value returned from the method in
a main method variable for later use.

? Method 1: a method to determine the rate for the plan.

o Method will have one input parameter: the number of lines on the plan

o Method will use the number of lines to determine the monthly rate for the plan

o Method will return the plan’s monthly rate

? Method 2: a method to determine the data
overage charge for the plan
.
o Method will have two input parameters: the number of lines on the plan,
and the data used by the plan for the current month

o The method should round the data used UP to the nearest whole GB,
and then calculate the charges

? NOTE: Charges will be 0.00 when customers do not go over their included data

o Method will return the data overage charge

? Method 3: a method to display a plan/usage summary

o Method will have two input parameters: the number of lines on the plan,
and the data used by the plan for the current month

o Method will display 2 blank lines first

o Method will display plan/usage summary, formatted as shown below

? All details should line up on the right with the last character in position 30

? Plan type should be displayed as a String (single or family)

? Data usage should be displayed rounded to 1 decimal place and include the units

? Method 4: a method to display the charges
o Method will have two input parameters: the plan’s monthly rate
and the data overage charge
o Method will display 1 blank line first
o Method will display the plan rate and overage charges, along with a total,
formatted as shown below

PLAN/USAGE SUMMARY
Plan: single
Number of lines: 1
Data usage: 2.5 GB
CHARGES
Plan rate 29.99
Data overage charges 8.49
-------
Total bill 38.48

Summary & Charges Output for Sample Run 2 (family plan with multiple lines and low data usage):

PLAN/USAGE SUMMARY
Plan: family
Number of lines: 3
Data usage: 5.5 GB
CHARGES
Plan rate 71.99
Data overage charges 0.00
-------
Total bill 71.99

Explanation / Answer

JAVA PROGRAM:

import java.util.Scanner;

import java.lang.*;

class CellPhoneBillGenerator{

   public static void main(String args[]){

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter customer plan type(S for single and F for family): ");

       char plan = sc.next().charAt(0);

     

       System.out.print("Enter data usage: ");

       float data_usage = sc.nextFloat();

     

       int number_of_line ;

       if(Character.toUpperCase(plan)=='S'){

           number_of_line = 1;

       }

       else{

           System.out.print("Enter numnber of lines: ");

           number_of_line = sc.nextInt();

           //given in question that minimum no of lines in case

           //of family plan is 2

           if(number_of_line<2)number_of_line=2;

       }

     

       float monthly_plan_rate = plan_rate(number_of_line);

     

       double data_overuse_charge = overuse_calculator(number_of_line,data_usage);

     

       display_plan_usage(number_of_line,data_usage);

       display_charges(monthly_plan_rate,data_overuse_charge);

   }

   //method1 as specified in question

   public static float plan_rate(int number_of_line){

       float addition_rate_3line = 22.00f;

       float above_3line_rate = 12.00f;

       float single_line_rate = 29.99f;

       float first_2line_rate = 49.99f;

       if(number_of_line==1)

           return single_line_rate;

     

       else{

           if(number_of_line==2){

               //return value for 2 line rate

               return first_2line_rate;

           }else if(number_of_line==3){

               //return value for 3 line rate

               return first_2line_rate + addition_rate_3line;

           }else{

               //return value for above 3 line rate

               return (first_2line_rate+addition_rate_3line+(number_of_line-3)*above_3line_rate);

           }

       }

   }

   //method2 as specified in question

  

   public static double overuse_calculator(int number_of_line, double data_usage){

       int data_usage_up = (int)Math.ceil(data_usage);

       double over_use_charge = 8.49;

       if((number_of_line*2)<data_usage)

           return (data_usage_up-(number_of_line*2))*over_use_charge;

       else

       return 0.00;

   }

   public static void display_plan_usage(int number_of_line,float data_usage){

       System.out.print(" ");

       System.out.println("PLAN/USAGE SUMMARY");

       if(number_of_line==1)

           System.out.println(String.format("%-20s %10s","Plan:","single"));

       else

           System.out.println(String.format("%-20s %10s","Plan:","family"));

       System.out.println(String.format("%-20s %10d","Number of lines:",number_of_line));

       System.out.println(String.format("%-17s %10.1f %s","Data usage:",data_usage,"GB"));

   }

   public static void display_charges(float monthly_plan_rate, double data_overuse_charge){

       System.out.print(" ");

       System.out.println("CHARGES");

       System.out.println(String.format("%-22s %8.2f","Plan rate:",monthly_plan_rate));

       System.out.println(String.format("%-22s %8.2f","Data overage charges:",data_overuse_charge));

       System.out.println(String.format("%31s ","-------"));

       System.out.println(String.format("%-22s %8.2f","Total bill",monthly_plan_rate+data_overuse_charge));

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote