Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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:

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

This is what I have for code,

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:\wamp64\www\test2\Movie.php on line 11

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions