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
Gre4nikov [31]
3 years ago
13

Create a program named MealPriceCalculation that prompts users enter a meal price and the tip and then calculate and display the

total meal price. The program should have a Main () and then use two overloaded methods of the same name to calculate and display the total meal price twice: the first one accepts a meal price (double) and a tip amount in dollars (double), and the second one accepts a meal price (double) and a tip in percentage (int) of the meal price.
Computers and Technology
1 answer:
Blizzard [7]3 years ago
4 0

Answer:

  1. import java.util.Scanner;
  2. public class MealPriceCalculation{
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        System.out.print("Enter meal price: ");
  6.        double meal = input.nextDouble();
  7.        System.out.print("Enter tip: ");
  8.        double tip = input.nextDouble();
  9.        calculatePrice(meal,tip);
  10.        calculatePrice(meal,(int)tip);
  11.    }
  12.    public static void calculatePrice(double meal, double tip){
  13.        System.out.println("Total meal price: $" + (meal + tip) );
  14.    }
  15.    public static void calculatePrice(double meal, int tip){
  16.        System.out.println("Total meal price $" + (meal+tip));
  17.    }
  18. }

Explanation:

The solution code is written in Java.

Overload methods are the methods that share the same name but with different method signature. In this question, we create two overload methods calculatePrice (Line 17-23). One version will accept parameter meal and tip in double type and another will accept parameter meal in double but tip in integer. Both of this method are doing the same job which is just printing the total of meal.

In the main program, create a Scanner object and use it to prompt user to input meal price and tip (Line 6-10).  Next call the calculatePrice method for twice. In the first time, pass meal and tip as double type data to calculatePrice method (Line 12). In the second time, pass meal in double but tip in integer to the method. Only the method with parameter list that match the argument data type will be implemented and output the total meal price.  

You might be interested in
To change a selected shape’s height or width to a specific value, type the value in the Height or Width text boxes on the
Scrat [10]
Are you trying to change the shape of an item within your program by entering the values into text boxes that become variables?

What language are you using?
5 0
3 years ago
What two methods can be used to access and modify an existing program that is running on an iot device in cisco packet tracer? (
dsp73

Cisco Packet Tracer is tool used for network simulation and visualization program.

The two methods can be used to access and modify an existing program that is running on an IoT device in Cisco packet trace are the following:

1. Click on the device then select the Programming tab.

2. Go to the registration server and login. Then select the Editor tab.

3 0
3 years ago
What is a network of high-capacity communication links is the internet?
mojhsa [17]

Social media is the high capacity of communication links

5 0
3 years ago
What Security Issu E Commerce ?​
Andre45 [30]

Answer:

e means we don't know so I can't tell the answer

5 0
2 years ago
All of the following are common causes of electrical accidents and injuries, EXCEPT:
mote1985 [20]
<h3>✽ - - - - - - - - - - - - - - - ~<u>Hello There</u>!~ - - - - - - - - - - - - - - - ✽</h3>

➷ It would be D. I don't really see how the plug itself is a cause of electrical accidents.

<h3><u>✽</u></h3>

➶ Hope This Helps You!

➶ Good Luck (:

➶ Have A Great Day ^-^

↬ ʜᴀɴɴᴀʜ ♡

7 0
3 years ago
Other questions:
  • to move from the second cell in the table in the accompanying figure back to the previous cell, press the ____ key(s)
    10·1 answer
  • What will be the value of i after the C statements at the right have been executed
    6·1 answer
  • Follow up, my brother is upset at me for stealing his robux, what should i do?
    11·2 answers
  • Programmers insert documentation called facts into the program code.? <br> a. True <br> b. False
    9·1 answer
  • What is the difference between head header and heading in HTML​
    8·1 answer
  • Ile 1 cm<br> ?<br> 50 m<br> The an
    5·2 answers
  • Uuhdcnkhbbbbhbnbbbbnnnnnnnnnfddjkjfs
    14·1 answer
  • GUYSSS!!!
    5·2 answers
  • I’ll mark brainliest, thanks
    10·2 answers
  • You respond to a fire at a pharmaceutical production plant. One of the outside storage tanks is on fire. The placard on the tank
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!