Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with PHP code Create a Movie class that determines the cost of a ticke

ID: 3741667 • Letter: N

Question

Need help with PHP code

Create a Movie class that determines the cost of a ticket to a cinema, based on the moviegoer's age. Assume that the cost of a full-price ticket is $10. Assign the age to a private data member. Use a public member function to determine the ticket price, based on the following schedule:

This is what I have for code,

<?php

class movie

{

private $custage=0;

public $movieticprice=10.00

function construct()

{

$this->custage=custage;

}

function calprice($movieticprice)

{

switch($this->custage)

{

case($this->custage < 5): // The first condition that if age is less than 5

$this->movieticketPrice = 0;

break;

case ($this->custage > 5 && $this->custage < 18):// second case if age is between 5 and 17 including both

$this->movieticketPrice = $movieticketPrice / 2;

break;

case ($this->custage >= 18 && $this->custage <= 55): // Third case If age is between 18 and 55 including both

$this->movieticketPrice = $movieticketPrice;

break;

case ($this->custage > 55): //The forth case with age greater than 55

$this->movieticketPrice = $movieticketPrice - (float) ("2.00");

break;

}

return $this->movieticketPrice;

}

}

?>

This is the error I am getting,

Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting ',' or ';' in C:wamp64www est2Movie.php on line 11

Age Price Under 5 Free 5 to 17 Half Price 18 to 55 Full Price Over 55 $2 off

Explanation / Answer

You have missed a semicolon before construct() function, that is why you are getting that error.

public $movieticprice=10.00;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote