Question
Qn1 a) Can a void method have a return statement? If your answer is yes, in what form? Write appropriate method headings for the following
Qn1
a) Can a void method have a return statement? If your answer is yes, in what form?
Write appropriate method headings for the following methods:
b) Calculate and return the sum of two decimal numbers.
c) Compute and return the average speed of a car, given the distance traveled (as in int) and traveling time (in hours and minutes of type int).
d) Given the radius of a circle, output the area of the circle.
e) Given a students name and three test scores (of type int), output the students name and average test score.
f) Given a number, return true if the number is a prime; otherwise, return false.
g) Given the cost of an item and the sales tax (as a decimal number), return the total sale price.
h) Given a decimal number, output the square root if the number is nonnegative; otherwise, output an appropriate error message.
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