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
Live footage refers to:
QveST [7]

Answer:

D

Explanation:

live refers to happening right now and footage refers to videos taken and captured.

8 0
1 year ago
Set numMatches to the number of elements in userValues (having NUM_VALS elements) that equal matchValue. Ex: If matchValue = 2 a
xenn [34]

Answer:

import java.util.Scanner;

public class FindMatchValue {

public static void main (String [] args) {

   final int NUM_VALS = 4;

   int[] userValues = new int[NUM_VALS];

   int i = 0;

   int matchValue = 0;

   int numMatches = -99; // Assign numMatches with 0 before your for loop

   userValues[0] = 2;

   userValues[1] = 2;

   userValues[2] = 1;

   userValues[3] = 2;

   matchValue = 2;

   numMatches=0;

   for(i=0;i<NUM_VALS;i++)

   {

       if(userValues[i]==matchValue)//cheking if the array element is equal to match value.

       {

           numMatches++;

           

       }

   }

   System.out.println(numMatches);//printing the matchvalue.

}

}

Output:-

3

Explanation:

First I have set the value numMatches to 0 before the loop.Then I have user the for loop to iterate over the array.In the for loop I am checking that the array element is equal to the matchValue or not if it is equal then increasing the numMatches by 1.Then at last print the value of numMatches.

5 0
3 years ago
What is the function of ctrl+Q​
vlabodo [156]

Answer:

Ctrl+Q is used to remove a paragraph's formatting

Explanation:

Hope that's the answer you're looking for!

5 0
2 years ago
Which of the descriptions listed below best describes the step in the reverse engineering process called functional analysis? A)
Zepler [3.9K]
If multiple choice then d and a if not then the best one would be a!


hope this helps!!
5 0
3 years ago
During the troubleshooting of a pc that will not boot, it is suspected that the problem is with the ram modules. the ram modules
Damm [24]
The modules were somehow disconnected
8 0
3 years ago
Other questions:
  • Wich of these is an example of magnetic storage
    11·1 answer
  • Consider what fact-finding techniques you would use to identify the important facts needed to develop a database system. Please
    7·1 answer
  • A user reports that she can't access the new server used in the accounting department. you check the problem and find out that h
    9·1 answer
  • #We've started a recursive function below called #measure_string that should take in one string parameter, #myStr, and returns i
    5·1 answer
  • Which of the following is NOT essential for individuals to have to build their own web page?
    9·1 answer
  • One advantage of using a security management firm for security monitoring is that it has a high level of expertise.
    15·2 answers
  • A student is curious about how a Web site appears on his computer screen. On a piece of paper,
    9·1 answer
  • Use the {blank} to view your presentation the way an audience will see it.
    13·2 answers
  • Pleasee helpppppppppppppppppppppp me!
    7·1 answer
  • Fifteen years ago, everyone didn't have a cell phone. Anyone developing an app would not have found many users. Today, the exist
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!