Objectives: Basic programming involving arithmetic, input, and output, output formatting, named constants, modular programming using methods, Simple decision making.

Functionality

The ABC Wireless Company offers its customers the following monthly plan:

The base charge for a month is $20, which includes 100 voice minutes, 100 text messages, and 100 MB Internet data.

Usages over the allowances are charged as follows:

  • Voice minutes over 100 are 5 cents/minute
  • Text messages over 100 are 2 cents/message
  • Data usage over 100 MB are 1 cents/100 KB of data, any fraction of 100 KB is charged as 100 KB

The purpose of the program is to compute a customer's monthly bill from the usage data.

  • A Sales Tax of 7.25% is added to the bill.

Program input

  • Customer's first name and last name (String, use the Scanner's next() method to read these; the full name can be calculated by concatenating the first name and the last name, add a blank space between the first and last names, see subsection 2.5.2 in the textbook)
  • Voice minutes (integer)
  • Text messages (integer)
  • Data usage (integer, in KB)

Calculations

The program needs to calculate the excess usage charges to be applied for various items (voice, text, data) in the service. Note that excess data usage will need to be rounded up to a multiple of 100 KB. So someone who used 123,456 KB of data will have to pay for 23,500 KB over plan allowance (which calculates to $2.35 for the data). The sales tax calculation can result in a fraction of a penny. This will need to be rounded to the nearest penny. You can use the round2 method from the previous assignment.

Program Output

The output from the program has two clear sections: The dialog with the user, and the displayed/printed bill. These two sections should be separated by a horizontal line (a bunch of hyphens). See sample output. Use System.out.printf for formatted output.

Program Structure

It is possible to write this program using just the "main" method, but you should break up the code into methods (similar to the sample program BasicIPOModular.java). All these methods will accept no parameters. The main method will do the following in sequence:

1.Print the output identification line CPS 150 Assignment 2 by your name
2.Call a method to get all input data (see above)
3.Call a method to calculate excess charges, sales tax and the total amount to be billed to customer. This method involves decision making.
4.Call a method to print the bill.
5.Print the sign-off line Assignment 2 complete

You may use the methods that combine prompting and getting input values from BasicIPOModular2.java.

Program style requirements

You should declare the variables and named constants at the class level, including the Scanner created on System.in when these are shared by methods. But any variable used in only one method should be declared as a local identifier within that method.

To get full credit for the assignment, you must do the following:

  • Use variable/constant/method names that are meaningful
  • Header block comments and sections comment should be given
  • Program text should be easy to read and nicely formatted (NetBeans can help with Source-> format)
  • Program output should be easy to read and well organized.

Sample results see image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.