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
What effect on total current flow will a shorted series component have in a series-parallel circuit?
Citrus2011 [14]
Im going to go with D on this one but dont rely on my answer this is just a  educated guess

7 0
3 years ago
What type of operating system is Linux? An outsourced operating system An open source operating system A closed source operating
Lesechka [4]

Answer:

An open source operating system

Explanation:

Linux is an open source operating system (OS). An operating system is the software that directly manages a system's hardware and resources, like CPU, memory, and storage.

8 0
3 years ago
Identify the tools on the boxes. write the answer
Gnom [1K]

Answer:

im going off of what i know =( 2 screw driver 3 zip ties 5 needle nose plyers 8 can air

Explanation:

5 0
3 years ago
A computer professional who has access to sensitive information shares this information with a third party. Which professional c
GalinKa [24]

Answer:

The answer is c.

Explanation:

hope this helps

7 0
4 years ago
Search for availability and pricing for a room for 2 adults and 2 kids (5 and 6 years old) for 4 nights in Madrid, Spain in abou
RoseWind [281]
Is this an actual asignment
4 0
3 years ago
Other questions:
  • Please Answer Fast will mark Brainliest!!!
    5·1 answer
  • When writing about environment concerns, which topic would demonstrate civic-mindedness on a global scale?
    11·2 answers
  • What are the computer/electronic needs<br> that drive our economy today?
    13·1 answer
  • Garrett wants to search through a csv file to find all rows that have either the name John or Bob in them and display them out t
    9·1 answer
  • Brad is joining a big website design firm. He is worried that he may not be able to adapt to the company culture. What can he do
    15·1 answer
  • Recall that two strings u and v are ANAGRAMS if the letters of one can be rearranged to form the other, or, equivalently, if the
    7·1 answer
  • A pizza delivery restaurant decides to stop hiring drivers and start hiring cyclers to deliver its pizza. The restaurant thinks
    15·1 answer
  • . Is it conceivable to design a secure operating system for these computer systems? Give arguments for and against.
    6·1 answer
  • Does anyone have 2.19.4 Guess a number 2.0 code for codehs?
    8·1 answer
  • Your company is getting negative feedback on the current customer service process. It’s your job to make sure customers are happ
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!