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
Which of the following statements is false? A.The concepts of icons, menus and windows were originally developed by Xerox PARC.
Fudgin [204]

Answer:

(b) Windows is an open source operating system (<em>This is not correct</em>)

Explanation:

Option a is <em>correct</em> because Xerox PARC(Palo Alto Research Center), which is a subsidiary of the Xerox corporation, has been greatly responsible for invention and development in modern computing devices. Some of these developments are in Ethernet and graphical user interface (making use of menus, icons e.t.c).

Option b is <em>not correct</em> because Windows Operating system is not an open source operating system. Open source OS means users can interact with the driving code of the OS and make modifications. Windows does not support this feature. Operating systems that are open source include Linux and OpenSolaris.

Option c is <em>correct</em>. An operating system has two main components - the kernel and the user interface. The core component of an operating system is the Kernel as it interacts directly with the hardware and manages system resources. The user interface on the other hand allows users to interact with the kernel of the operating system using texts and/or graphics as commands.

Option d is <em>correct</em>. Linux operating system is an open source OS. Therefore, the source code is made available to the public for examination and modification.

8 0
3 years ago
Please Help!!!<br> I keep getting this answer wrong
IgorC [24]

Answer:

I think its option a. and d.

Explanation:

option a. is right I'm sure.

option b. and c. are doubtful for me.

option d. can be true. but unlike a job letter, resumes carry a deeper view of the employee's accomplishments and qualifications.

but I still hold with option a. and b. if it's wrong please do inform, so I can refer.

5 0
3 years ago
A linear gradient can be positioned from left to right, top to bottom, or on any angle?
Harman [31]

from left to right because it is used more in expressions

3 0
2 years ago
Which is a network of devices built around a person, typically within 10 meters of range?
11111nata11111 [884]

Answer:

A LAN

Explanation:

A LAN, or a Local Area Network, is a network of devices typically within 10 meters of range regardless of what it is built around.

6 0
3 years ago
What is known as networking in the IT field
Leona [35]

Networking, also known as computer networking, is the practice of transporting and exchanging data between nodes over a shared medium in an information system.

3 0
2 years ago
Other questions:
  • Write a copy assignment operator for CarCounter that assigns objToCopy.carCount to the new objects's carCount, then returns *thi
    15·1 answer
  • Describe in 2–3 sentences how you would use the autosum shortcut.
    9·2 answers
  • Assume you have a sorting algorithm that you can use as a black box. Use the sorting algorithm to sort the input list. Now write
    10·1 answer
  • In modern computer systems, a byte consists of
    14·1 answer
  • You maintain an RODC running Windows Server 2012 R2 at a branch office, and you want Juanita, who has solid computer knowledge,
    13·1 answer
  • What is the single most important component of a computer? Central Processing Unit DIP Motherboard Chipset
    8·1 answer
  • Can i edit my name on this app?
    7·1 answer
  • PLZ ANSWER THESE QUESTIONS FOR 30 POINTS AND BRAINLIEST!
    9·1 answer
  • Full form of http.<br>wrong answer will be reported ​
    6·2 answers
  • Why is computer called information processing machine ?????​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!