# In a pseudocode program,,,write a program that computes and displays a 15b percent tip when the price of a meal input by the user.(Hint: the tip is computed by multiplying the price of the meal by 0.15 ) You will need the following Variables: MealPrice (a Float) Tip (a Float) To accomplish the completion of this program, you would only need a single function to determine the tip total. The function would look something like this:

public float getTip(float mealPrice) {

return mealPrice * 0.15;

}

Just as a reminder, since we have a constant (0.15), it is good...

Start your 48-hour free trial to unlock this answer and thousands more. Enjoy eNotes ad-free and cancel anytime.

To accomplish the completion of this program, you would only need a single function to determine the tip total. The function would look something like this:

public float getTip(float mealPrice) {

return mealPrice * 0.15;

}

Just as a reminder, since we have a constant (0.15), it is good coding practice to have a final variable at the top (above your main function) that can be in place instead of a hard coded value. A final variable at the top makes the code look much more readable. The variable can be at the top, like so:

private static final float TIP_PERCENTAGE = 0.15f;

Then the function would look like this:

public float getTip(float mealPrice) {

return mealPrice * TIP_PERCENTAGE;

}

Finally, this is how you would call the function and display the calculation:

public static void main(String[] args) {

float mealPrice = 5.00f;

float calculation = getTip(mealPrice);

System.out.println("Price: " + calculation);

}

Approved by eNotes Editorial Team