mardi 27 octobre 2020

Telco (using if else nested statements)

Dear StackOverflowers,

Telco Problem Description

Telco is a cellular telephone company that offers two types of service: standard and premium. Its rates vary, depending on the type of services. The rates are computed as follows:

Rates

Calculate the amount due if given a service code (s or S means standard service; a service code of p or P means premium service), and the number of minutes the service was used.

For the premium service, the customer may be using the service during the day and the night. Therefore, to calculate the bill, you must ask the user to input the number of minutes the service was used during the day and the number of minutes the service was used during the night.

Input Description:

There are service code (s, S, p or P) and usage amount u (u≥0). If the service code is p or P, then the usage has two types; day usage du(du≥0) and night usage nu(nu≥0).

Output Description:

The format is RMt where t is the amount due in Malaysia currency format as shown in the sample output.

Hint: Use the following declaration and statement for output formatting

import java.text.DecimalFormat;

DecimalFormat df = new DecimalFormat("0.00");

System.out.println("RM" + df.format(total));

Sample Input Output: sample input for program

Aucun commentaire:

Enregistrer un commentaire