Question

PLEASE DO THIS IN JAVA!Design (pseudocode) and implement (source code) a program (name it PhoneBill) that...

PLEASE DO THIS IN JAVA!Design (pseudocode) and implement (source code) a program (name it PhoneBill) that calculates the bill for a cellular telephone company. The company offers two types of service: regular service and premium service. The rates vary depending on the type of service. The rates are computed as follows: Regular service: $15.00 fee covering first 50 minutes. Charges for over 50 minutes are computed at the rate of $0.50 per minute. Premium service: $25.00 fee plus: a. For daytime calls (between 6:00AM to 6:00PM), the first 50 minutes are free; charges for over 50 minutes are computed at the rate of $0.20 per minute. b. For nighttime calls (between 6:00PM to 6:00AM), the first 100 minutes are free; charges for over 100 minutes are computed at the rate of 0.10 per minute. The program prompts the user to enter an account number, a service code (of type char), and the number of minutes the service was used. A service code r (or R) means regular service; while code p (or P) means premium service. If the service is premium (code p or P), the customer may be using the service during both the day and night. Therefore, the program must ask the user to input the number of minutes used during daytime and nighttime in separate prompts. Document your code and properly label the input prompts and the outputs as shown below. Sample run 1: Account Number: 12345 Service type: Regular Total minutes: 50 Amount due: $15.00 Sample run 2: Account Number: 32145 Service type: Premium Daytime minutes: 40 Nighttime minutes: 200 Amount due: $35.00 Sample run 3: Account Number: 78654 Service type: Premium Daytime minutes: 60 Nighttime minutes: 120 Amount due: $29.00

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

Answer:-

The below is the required source code for the given problem in JAVA

Code:-

import java.util.Scanner;

class PhoneBill{

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

int account_number, total_due = 0;

char service_code;

System.out.print("Enter Account Number: ");

account_number = in.nextInt();

System.out.print("Enter Service code(R/P): ");

service_code = in.next().toUpperCase().charAt(0);

int minutes=0, daytime=0, nighttime=0;

if(service_code=='R'){

total_due = 15;

System.out.print("Number of minutes the service used: ");

minutes = in.nextInt();

if(minutes>50)

total_due += (minutes-50)*0.50;

}

else if(service_code=='P'){

total_due = 25;

System.out.print("Number of munutes used during the daytime: ");

daytime = in.nextInt();

System.out.print("Number of munutes used during the nighttime: ");

nighttime = in.nextInt();

if(daytime>50)

total_due += (daytime-50)*0.20;

if(nighttime>100)

total_due += (nighttime-100)*0.10;

}

else{

System.out.println("Invalid service code");

System.exit(0);

}

System.out.println("\n\nAccount Number:\t"+account_number);

System.out.println("Service type:\t"+(service_code=='R'?"Regular":"Premium"));

if(service_code=='R'){

System.out.println("Total minutes:\t"+minutes);

System.out.println("Amount due:\t$"+total_due);

}

else{

System.out.println("Total minutes during day time:\t"+daytime);

System.out.println("Total minutes during night time:\t"+nighttime);

System.out.println("Amount due:\t$"+total_due);

}

}

}

In the above code I done for first sample run for second sample run please change the values. If you find any difficulty with the code, please let know know I will try for any modification in the code. Hope this answer will helps you. If you have even any small doubt, please let me know by comments. I am there to help you. Please give Thumbs Up,Thank You!! All the best

Add a comment
Know the answer?
Add Answer to:
PLEASE DO THIS IN JAVA!Design (pseudocode) and implement (source code) a program (name it PhoneBill) that...
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
  • PLEASE DO THE PSEUDOCODE FOR THE PROGRAM BELOW Program 3: Design (pseudocode) and implement (source code)...

    PLEASE DO THE PSEUDOCODE FOR THE PROGRAM BELOW Program 3: Design (pseudocode) and implement (source code) a program (name it DistinctValues) to display only district values in an array. The program main method defines a single-dimensional array of size 10 elements and prompts the user to enter 10 integers to initialize the array. The main method then calls method getValues() that takes an integer array and returns another single-dimensional array containing only distinct values in the original (passed) array. Document...

  • PLEASE DO IN PYTHON Program 2: Design (pseudocode) and implement (source code) a program (name it...

    PLEASE DO IN PYTHON Program 2: Design (pseudocode) and implement (source code) a program (name it FeetMeters) to display a conversion tables for feet and meter as show below. Document your code and properly. Feet Meter 1.0 0.305 2.0 0.610 3.0 0.915 . . . . . . 19.0 5.7.95 20.0 6.100 Meter Feet 1.0 3.279 2.0 6.558 3.0 9.837 . . . . . . 19.0 62.301 20.0 65.574 The program defines the following methods: Method feetToMeter() converts from...

  • Design (pseudocode) and implement (source code) a program (name it IncomeTax) that reads from the user...

    Design (pseudocode) and implement (source code) a program (name it IncomeTax) that reads from the user annual income, as integer value, and calculates the income tax based on the tax table below. Income Tax bracket Annual income <= $50,000 5% $50,000 < Annual income <= $200,000 10% $200,000 < Annual income <= $400,000 15% $400,000 < Annual income <= $900,000 25% $900,000 < Annual income 35% The program output should include the entered annual income followed by the applied tax...

  • PSEUDOCODE and PYTHON source code! Program 4: Design (pseudocode) and implement (source code) a program (name...

    PSEUDOCODE and PYTHON source code! Program 4: Design (pseudocode) and implement (source code) a program (name it MinMaxAvg) to determine the highest grade, lowest grade, and the average of all grades in a 4-by-4 two-dimensional arrays of integer grades (representing 4 students’ grades on 4 tests). The program main method populates the array (name it Grades) with random grades between 0 and 100 and then displays the grades as shown below. The main method then calls method minMaxAvg()that takes a...

  • please do the program in simple programming it is for my first c++ computer class i...

    please do the program in simple programming it is for my first c++ computer class i posted the example on pic 2,3 which is how this should be done Write a program that calculates and prints the bill for a cellular telephone company. The company offers two types of services: regular and premium. Its rates vary depending on the type of service. The rates are computed as follows: Regular service: $10.00 plus the first 50 minutes are free. Charges for...

  • Do this in Python please Program 2: Design (pseudocode) and implement (source code) a program (name...

    Do this in Python please Program 2: Design (pseudocode) and implement (source code) a program (name it FeetMeters) to display a conversion tables for feet and meter as show below. Document your code and properly. Feet Meter 1.0 0.305 2.0 0.610 3.0 0.915 . . . . . . 19.0 5.7.95 20.0 6.100 Meter Feet 1.0 3.279 2.0 6.558 3.0 9.837 . . . . . . 19.0 62.301 20.0 65.574 The program defines the following methods: Method feetToMeter() converts...

  • : Design (pseudocode) and implement (source code) a program (name it Circles) to determine if a...

    : Design (pseudocode) and implement (source code) a program (name it Circles) to determine if a circle is either completely inside, overlapping with, or completely outside another circler. The program asks the user to enter the center point (X1, Y1) and the radius (R1) for the first circle C1, and the center point (X2, Y2) and the radius (R2) for the second circle C2. The program then determines if the second circle C2 is either completely inside, or overlapping with,...

  • Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the...

    Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the following 3 methods: Method isValid() returns true if the sum of the width and height is greater than 30 Method Area() returns the area of the rectangle if it is a valid rectangle Method Perimeter() returns the perimeter of the rectangle if it is a valid rectangle The main method of MyRectangle prompts the user to enter the width and height of a rectangle...

  • Program 5: Design (pseudocode) and implement (source code) a program (name it Weekl yHours) to compute...

    Program 5: Design (pseudocode) and implement (source code) a program (name it Weekl yHours) to compute the total weekly hours for 3 employees. The program main method defines a two-dimensional array of size 3x7 to store employers' daily hours for the week. Each row represents one employee and each column represent one day of the week such that column 0 designates Monday, column 1 designates Tuesday, etc. The program main method populates the array with random numbers between 0 and...

  • Kilobytes Systems has moved from Distribution of computer peripherals and accessories to provide Telephone a programmer...

    Kilobytes Systems has moved from Distribution of computer peripherals and accessories to provide Telephone a programmer to calculate and prints client's bill for services and has contracted you as cellular telephone usage. The kilobytes offers two types of service: golden and platinum. Its rates vary, depending on type of service. The rates are computed as follows: Golden service: 20.00 plus first 100 minutes are free charges for over 100 minutes are 20 cents per minute and 4 cents if you...

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