From the course: Learning Java 11

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Parameters in Java

Parameters in Java - Java Tutorial

From the course: Learning Java 11

Start my 1-month free trial

Parameters in Java

- [Instructor] The announceDeveloperTeaTime function had no inputs. It was just a series of steps that the program followed every time the function was called. The output was always the same. There was nothing dynamic about it. What if I wanted the output to be different depending on what was inputted into the function? For example, let's say I wanted to calculate the total cost of a meal including tip and tax. To calculate this we would first figure out the tip by multiplying the tip rate with the listed price of the meal. We would figure out the tax by multiplying the tax rate with the listed price of the meal as well. Then we would add the tip, tax, and listed price of the meal and output the result. These are finite steps that we can label calculateTotalMealPrice. Of course, almost every meal you order will have a different listed price. And sometimes you might want to tip a different rate depending on what service you get. And sometimes you might want to tip a different rate…

Contents