Name: Program: Studentid: Group: Q1.Write Method Headers (Not The Bodies) For The Following Methods
Name: Program: Studentid: Group: Q1.Write Method Headers (Not The Bodies) For The Following Methods
Write your answer and submit on time via VLE OOP _ Pre Assessment 5 October 2022
Name : Program:
StudentId: Group:
Q1.Write method headers (not the bodies) for the following methods:
a. Return a sales commission, given the sales amount and the commission rate.
b. Display the calendar for a month, given the month and year.
d. Return the monthly payment, given the loan amount, number of years, and annual interest rate.
// Method body
// Method body
// Method body
// Method body
}
Instruction:
Write your answer and submit on time via VLE OOP _ Pre Assessment 5 October 2022
a. The method public static double sum(double x, double y) is not invoked for double z = sum(4, 5);
because the arguments 4 and 5 are both integers and do not match the method signature.
b. The method public static double sum(int x, double y) is invoked for double z = sum(4, 5.4);
because the first argument 4 is an integer and the second argument 5.4 is a double. The compiler
performs an implicit conversion of the integer 4 to a double before invoking the method.
c. The method public static double sum(double x, double y) is invoked for double z = sum(4.5, 5.4);
because both arguments 4.5 and 5.4 are doubles and match the method signature.
return meter;
return foot;