Question

Java Programming Problem description with its major requirements labeled from A to I. A mobile phone...

Java Programming

Problem description with its major requirements labeled from A to I.

A mobile phone service provider has three different subscription packages for its customers: Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute. Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute. Package C: For $69.99 per month unlimited minutes are provided.

Design a class MobileCharges that calculates a customer’s monthly bill. It should store the letter of the package the customer has purchased (A, B, or C) (A) and the number of minutes that were used (B). It should have a method getTotalCharges(). that returns the total charges (C).

Your program should use a non-default constructor as the following (D) public MobileCharges(char packageChoice, double minutes)

The program should calculate the total changes in the constructor’s body (E).

Your program should get the total charges using a method getTotalCharges()

Your program should accept both capital or small letter for each choice (F).

Your program should check for incorrect option character and show error message (G)

The program should display the total charges with two digits after decimal point (H).

Demonstrate the class in a program that asks the user to select a package and enter the number of minutes used (I).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

import java.util.*;
import java.io.*;

public class MobileCharges
{
    private double totalCharges;
    public MobileCharges(char packagechoice,double minutes)//constructor
    {
        if(packagechoice=='a'||packagechoice=='A')//accepts both small and capital letters
        {
            if(minutes<=450)
                totalCharges = 39.99;
            else
                totalCharges = 39.99 + (minutes-450)*0.45;
        }
        else if(packagechoice=='b'||packagechoice=='B')
        {
            if(minutes<=900)
                totalCharges = 59.99;
            else
                totalCharges = 59.99 + (minutes-900)*0.40;
        }
        else if(packagechoice=='c'||packagechoice=='C')
                totalCharges = 69.99;

    }

    public double getTotalCharges()
    {
        return totalCharges;
    }

    public static void main(String args[]) throws Exception
    {
            char a;
            double min,finalcharges;
            Scanner in=new Scanner(System.in);
            
            //taking input from user
            System.out.print("Enter the package you have opted for: ");
            a=in.next().charAt(0);
            while(a!='A'&&a!='a'&&a!='B'&&a!='b'&&a!='C'&&a!='c')//for invalid input
            {
                System.out.print("Invalid input, enter again: ");
                a=in.next().charAt(0);
            }
            System.out.print("Enter the total number of minutes: ");
            min=in.nextDouble();

            MobileCharges obj=new MobileCharges(a,min);
            finalcharges=obj.getTotalCharges();
            System.out.printf("The total charges for pacakge "+a+" for "+min+" minutes "+ " is %.2f",finalcharges);
    }
}

Output:

Add a comment
Know the answer?
Add Answer to:
Java Programming Problem description with its major requirements labeled from A to I. A mobile phone...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write in C++ Problem 1: Mobile Service Provider A cell phone service provider has three different...

    write in C++ Problem 1: Mobile Service Provider A cell phone service provider has three different subscription packages for its customers. Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute. Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute. Package C: For $69.99 per month unlimited minutes provided. Write a program that calculates a customer’s monthly bill. It should ask which package the customer has purchased...

  • Part 1: A mobile phone service provider has three different data plans for its customers: Package...

    Part 1: A mobile phone service provider has three different data plans for its customers: Package A: For $39.99 per month 4 gigabytes are provided. Additional data costs $10 per gigabyte. Package B: For $59.99 per month, 8 gigabytes are provided. Additional data costs $5 per gigabyte. Package C: For $69.99 per month, unlimited data is provided. Write a program that calculates a customer's monthly bill. It should ask which package the customer has purchased and how many gigabytes were...

  • write in java and you must use methods.... Part I     Internet Service Provider An Internet service...

    write in java and you must use methods.... Part I     Internet Service Provider An Internet service provider has three different subscription packages for its customers: Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour. Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour. Package C: For $19.95 per month unlimited access is provided. Write a program that calculates a customer’s monthly bill....

  • Problem: Mobile Service Provider A mobile service provider has three different subscription packages for its customers:...

    Problem: Mobile Service Provider A mobile service provider has three different subscription packages for its customers: • Package A: For $50 per month, 5 GB data are provided. Additional data is $15 per GB. • Package B: For $65 per month, 10 data are provided. Additional data is $10 per GB. • Package C: For $75 per month unlimited data provided. Text messaging and voice services are included in all of the company's data packages. The Mobile Service Company offers...

  • In PYTHON code: Examples of output are as follows: If the user entered Package A and...

    In PYTHON code: Examples of output are as follows: If the user entered Package A and 30 GB of data, then you should get the following output: Mobile Service Provider Enter your mobile phone package (A, B or C): A How many gigabytes data did you use? 30 Your total cost for Package A is 299.99 If you had chosen Package C you would have saved $ 230.00 If you had chosen Package B you would have saved $ 130.00...

  • Please can someone help me with making this program in JAVA implementing classes. Also, include loops...

    Please can someone help me with making this program in JAVA implementing classes. Also, include loops and selection structures. A mobile service provider has three different subscription packages for its customers: Package A: For $50 per month, 5 GB data are provided. Additional data is $15 per GB. Package B: For $65 per month, 10 data are provided. Additional data is $10 per GB. Package C: For $75 per month unlimited data provided. Text messaging and voice services are included...

  • An Internet service provider has three different subscription packages for its customers: Package A: For $15...

    An Internet service provider has three different subscription packages for its customers: Package A: For $15 per month with 50 hours of access provided. Additional hours are $2.00 per hour over 50 hours. Assume usage is recorded in one-hour increments. Package B: For $20 per month with 100 hours of access provided. Additional hours are $1.50 per hour over 100 hours. Package C: For $25 per month with 150 hours access is provided.    Additional hours are $1.00 per hour...

  • An Internet service provider offers four subscription packages to its customers, plus a discount for nonprofit...

    An Internet service provider offers four subscription packages to its customers, plus a discount for nonprofit organizations: Package A: 10 hours of access for $12.95 per month. Additional hours are $4.00 per hour. Package B: 20 hours of access for $14.95 per month. Additional hours are $2.00 per hour. Package C: 30 hours of access for $20 per month. Additional hours are $1.00 per hour. Package D: Unlimited access for $35.95 per month. A nonprofit organizations will get 20% discount...

  • Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses:...

    Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required.    Project Requirements Develop a text...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT