When purchasing this document, please ensure that it aligns with your assignment specifications and
requirements. This document is intended to serve as a reference or guide. It is crucial to thoroughly
review and customize the content to meet the unique criteria of your assignment. Failure to do so may
result in academic consequences. Use this document responsibly and in accordance with your
institution's academic integrity policies.
ict3612
QUESTION 1
<?php
//WRITE THE FUNCTION BELOW AS PER THE QUESTION. NO CODE TO INVOKE THE FUNCTION SHOULD
BE INCLUDED HERE
//NO HTML ALLOWED. ONLY PHP CODE IS ALLOWED
function processNumbers(...$args) {
$maxNumber = null;
foreach ($args as $arg) {
if (is_numeric($arg)) {
if ($maxNumber === null || $arg > $maxNumber) {
$maxNumber = $arg;
}
}
}
return $maxNumber;
}
?>
QUESTION 2
<?php
$stdin = fopen("php://stdin", "r"); //DO NOT CHANGE THIS LINE
$input_number = (int)fgets($stdin); //DO NOT CHANGE THIS LINE, $input_number will store the number
(1 to 3)
$input_string = trim(fgets($stdin)); //DO NOT CHANGE THIS LINE, $input_string will store the input string
// Function mappings
$functions = [
1 => 'strlen',
, 2 => 'strrev',
3 => 'ucwords'
];
// Check if the input number is within the valid range
if (isset($functions[$input_number])) {
$function = $functions[$input_number];
$output_string = $function($input_string);
} else {
$output_string = "Invalid input number";
}
echo $output_string; //DO NOT CHANGE THIS LINE, $output_string must store the output (changed
string)
?>
QUESTION 3
<?php
//WRITE THE CLASS AS PER THE QUESTION.
//NO HTML ALLOWED. ONLY PHP CODE IS ALLOWED
class MotorVehicle {
private $licenseNumber;
private $make;
private $series;
// Constructor to initialize the properties
public function __construct($licenseNumber, $make, $series) {
$this->licenseNumber = $licenseNumber;
$this->make = $make;
$this->series = $series;
}
// Method to return the string representation of the object
public function __toString() {
return "License Number: $this->licenseNumber, Make: $this->make, Series: $this->series";
}
// Static method to compare the make of two MotorVehicle objects
public static function compareMakes($vehicle1, $vehicle2) {
return $vehicle1->make === $vehicle2->make ? "Yes" : "No";
}
}
//CODE TO TEST THE CLASS, DO NOT CHANGE IT
$mv1 = new MotorVehicle("BGS954GP", "Toyota", "Corolla");