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

html/javascript Build a script to determine the cost of a movie ticket. Movies t

ID: 3747568 • Letter: H

Question

html/javascript

Build a script to determine the cost of a movie ticket. Movies that begin prior to noon on a weekday cost $10 for adults (18 or older) and $5 for children (under 18). Otherwise, tickets are $15 each for adults and $12 for children. If a movie is rated "R", the customer cannot purchase the ticket if not an adult. Finally, senior citizens (over 65) get a 10% discount. Show all the details along with the ticket price after all data has been entered. Invalid data must be repeatedly asked until valid.

Explanation / Answer

<html>

<script>

var number=prompt("Enter the day number:")

//Day numbers are from 1 to 7 where 1 to 5 represent weekdays and 6,7 represent weekends//

var time_string=prompt("Enter time in 24 hr format");

var time=Float.parseFlaot(time_string)

var cost=15

var Rating;

if(Rating=='R'&& age<18)

document.write("You are too young!")

else

ticket();

function ticket()

{

if(time<12 && number<=5)

{

if(age<18)

{

cost=5

}

else if(age>18&&age<65)

{

cost=10

}

else if(age>=65)

{

cost=cost*0.9

}

}

else{

if(age<18)

{

cost=12

}

else if(age>18&&age<65)

{

cost=15

}

else if(age>=65)

{

cost=cost*0.9

}

}

document.write('Cost of ticket is'+cost)

}

</script>

</html>