Question
Question (1) Write the definition of a function printDottedLine, which has no parameters and doesn't return anything. The function prints to standard output a single
Question (1) Write the definition of a function printDottedLine, which has no parameters and doesn't return anything. The function prints to standard output a single line (terminated by a new line character ) consisting of 5 periods.
Question (2) Write the definition of a function printGrade, which has a char parameter and returns nothing. The function prints on a line by itself the message string Grade: followed by the char parameter (printed as a character ) to standard output . Don't forget to put a new line character at the end of your line.
Thus, if the value of the parameter is 'A', the function prints out Grade: A
Question (3) Write the definition of a function square, which receives an integer parameter and returns the square of the value of the parameter .
So if the parameter 's value is 7, the function returns the value 49. If the parameter 's value happens to be 25, the functions returns the value 625. If the value of the parameter is 0, the function returns 0.
Question (4) Write the definition of a function absoluteValue, that receives an integer parameter and returns the absolute value of the parameter 's value .
So, if the parameter 's value is 7 or 803 or 141 the function returns 7, 803 or 141 respectively. But if the parameter 's value is -22 or -57, the function returns 22 or 57 (same magnitude but a positive instead of a negative). And if the parameter 's value is 0, the function returns 0.
Question (5) Write the definition of a function signOf, that receives an integer parameter and returns a -1 if the parameter is negative, returns 0 if the parameter is 0 and returns 1 if the parameter is positive.
So, if the parameter 's value is 7 or 803 or 141 the function returns 1. But if the parameter 's value is -22 or -57, the function returns -1. And if the parameter 's value is 0, the function returns 0.
Question (6) Write the definition of a function isPositive, that receives an integer parameter and returns true if the parameter is positive, and false otherwise.
So, if the parameter 's value is 7 or 803 or 141 the function returns true . But if the parameter 's value is -22 or -57, or 0, the function returns false .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started