1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
OleMash [197]
2 years ago
11

Write a program that calculates the cost of a phone call. The user enters a positive integer that

Computers and Technology
1 answer:
san4es73 [151]2 years ago
5 0
Add the following constants in the class definition, before the main method:

    private final static float START_COST = 1.5f;
    private final static float HIGH_TARIFF = 0.5f;
    private final static float LOW_TARIFF = 0.25f;
    private final static int FIXED_MINS = 2;
    private final static int HIGH_TARIFF_MINS = 10;

Then add this to the main method you already had:

        float price = START_COST;
        if (x > FIXED_MINS) {
            if (x <= HIGH_TARIFF_MINS) {
                price += HIGH_TARIFF*(x-FIXED_MINS);
            }
            else {
                price += HIGH_TARIFF*(HIGH_TARIFF_MINS-FIXED_MINS) 
                    + LOW_TARIFF*(x-HIGH_TARIFF_MINS);
            }
        }   
        System.out.printf("A %d minute call costs %.2f", x, price);      

You might be interested in
Text line breaks and returns are controlled using which tags?
eduard
<b></b> <span>element when used to strongly emphasize portions of text within a document.
<p></p> </span><span>tag defines a paragraph.
<ol></ol> </span><span>Defines an ordered list
<a></a> </span><span> tag defines a hyperlink</span>
5 0
3 years ago
Read 2 more answers
At some point in your driving career, you will most likely be faced with an oncoming vehicle swerving into your travel lane. tru
aleksley [76]

I believe the answer is True.

7 0
3 years ago
Which of the below is an example of a boolean?
AlladinOne [14]

Answer:

true

Explanation:

8 0
3 years ago
3 things you will do while driving
tino4ka555 [31]

Umm..let’s see hold the steering week look at the road and look on my phone for directions

4 0
2 years ago
What is the newest code language?​
pickupchik [31]

Answer:

<u>Python 3</u>

Explanation:

The language's latest iteration, Python 3.9, was released on October 5, 2020. It includes even more new features such as relaxed grammar restrictions, flexible function and variable annotations, and new string methods to remove prefixes and suffixes.

5 0
2 years ago
Read 2 more answers
Other questions:
  • 2. A body is thrown vertically<br>100 m/s Theme taken to retum​
    13·1 answer
  • True / False
    5·1 answer
  • Which part of the computer stores and processes data?
    14·1 answer
  • Which type of profile allows a user within a corporation to use the same user profie regardless of the computer that user is usi
    12·1 answer
  • Simplify the Boolean expression AB+(AC)`+AB`C(AB+C)
    13·1 answer
  • You have a sales chart and excel that you want to include in a 3rd quarter report to include in a 3rd quarter report quit it in
    7·1 answer
  • Which type of choir often sings AND dances while they perform?
    9·1 answer
  • 1. Why does a computer have different types of ports?
    14·2 answers
  • Write a C++ line of code to declare a variable of type “double” that signifies the average of student grades, then initialize th
    6·1 answer
  • Looking for similarities between concepts or problems is referred to as
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!