Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a 3.html and a3.js files and link the two files. Your HTML page must not have any validation errors and should have a descriptive

Create  a 3.html and a3.js files and link the two files. Your HTML page must not have any validation errors and should have a descriptive title, descriptive ids, and proper style.


Part 1: Valid Positive Number

Write the isValidPositiveNumber function

Parameters: One string parameter that we will validate

Operation: Check if the string will successfully convert to a valid positive number. It must not convert into NaN and after conversion, it's value must be greater than 0.

Returns: true if the string converts to a valid positive number, false if not


This is a function that will be useful in part 2. Do not add any elements to the HTML page for it. You can use the console to test it.


image

Part 2: Movie Ticket Price Add a heading, output paragraph, and button to the HTML page. Create a function for the button to call that uses two prompts to ask a user how old they are (in years) and the title of the movie they want to see. If either value is invalid, we will display an error message. Use the function from part 1 to validate the age value. If either value is invalid, display a message in the output paragraph explaining cl O The number is invalid if it is not a positive number (use your function from part 1) The title is invalid if it's length is 0 O If both values are valid, calculate the price of the ticket as follows. O The base price of the ticket is based on the length of the title. The movie costs $2 per character in the title. The minimum base price is $5 and the maximum is $30. Just check the length of the string, spaces, punctuation, numbers, etc, are all include in the length. If the string is too long or too short, you'll use the minimum/maximum price. O If the user is younger than 10 or older than 60, they receive a $3 discount to the base price. Display one of the following messages with the correct values based on the input/calculations You did not enter a valid age. You must enter a positive number. You did not enter a valid title. The title must have at least one character. A regular ticket for IT is $5 A discount ticket for IT is $2 A regular ticket for Ghostbusters costs $24 A discount ticket for Ghostbusters costs $21 A regular ticket for Everything Everywhere All At Once is $30 A discount ticket for Everything Everywhere All At Once is $27

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

Step: 3

blur-text-image

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Algorithms questions

Question

Evaluate the following, accurate to the nearest cent.

Answered: 1 week ago

Question

Evaluate the following, accurate to the nearest cent.

Answered: 1 week ago

Question

Evaluate the answers accurate to the cent. 3(6 + 4)2 - 5(17 - 20)2

Answered: 1 week ago