The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
1. Create a method named getOperands. This method does not return a value. In thisÂ
method, prompt the user twice. At the first prompt, ask them to enter a doubleÂ
variable. Name it operand1. At the second prompt, ask them to enter another doubleÂ
variable. Name it operand2. Use suitable data validation to ensure the variablesÂ
receive a double value. Another data validation is that operand1 and operand 2 use aÂ
positive value of at least 2.00 and less than 40.00. Another data validation is thatÂ
operand1 is less than or equal to the value in operand2. Keep prompting the user, ifÂ
necessary, until all data validations are passed.Â
2. Now that data validations have been enforced, from getOperands, pass both doubleÂ
variables to a method named calcPercentage. This method does not return a value. ItÂ
should display the first received value (i.e. operand1's value) as a percentage of theÂ
second received value (i.e. operand2's value). For example, if the method receivesÂ
numbers of 2.0 and 5.0, the method should output the following to the command line:Â
"The value of 2.0 is X percent of 5.0." where X is the percentage.Â
3. Use method overloading by creating three methods, each named buildName. The firstÂ
version of buildName should accept two String values named nameFirst and nameLast. Â
These are assigned by you in the main method; no user input is needed. The methodÂ
should return a String of the name parts in reverse order, separated by a comma andÂ
space. For example, if the first version of buildName receives "Santa" and "Claus",Â
it should return the following value:
"The full name reversed is:Â Claus, Santa"Â
4. The second version of buildName should accept a String value named nameFirst, aÂ
character value named nameMI, and a String value named nameLast. These are assignedÂ
by you in the main method; no user input is needed. The method should return a StringÂ
of the name parts in reverse order, separated by a comma and space. Append a periodÂ
for the middle initial. For example, if the second version of buildName receivesÂ
"Santa", "Q", and "Claus", it should return the following value:
"The full name reversed is:Â Claus, Santa Q."Â
5. The third version of buildName should accept a String value named nameFirst, aÂ
character value named nameMI, a String value named nameLast, and an integerÂ
representing an age. These are assigned by you in the main method; no user input isÂ
needed. The method should return a String of the name and age parts in reverse order,Â
separated by a comma and space. Append a period for the middle initial and includeÂ
the age. For example, if the third version of buildName receives "Santa", "Q", "Claus",Â
and 42, it should return the following value:
"The full name reversed and age are:Â Claus, Santa Q. (42 years old)"Â
6. Call each of the methods above from the main method. The pseudocodeÂ
for the main method will be as given below.Â
   Get the operands and ensure data validations are passed
   Calculate the percentage of the operands
   Output the reversed full name and age, depending on the values being provided
-----------