Question

The full price of a plane ticket is 800$ for example, but discounts are applied to...

The full price of a plane ticket is 800$ for example, but discounts are applied to it based on different criteria. The following rules determine the discount, and hence the final price:  Students get 30% discount.  People who purchase in 30 days in advance get 20% discount

. Discount can aggregate, for example, a student purchasing 30 days in advance gets a 50% discount. You have to ask the user for input on whether they are a student. After you display the final price to the user, you allow the user to enter another price. Design the form the performs this. ( Hint : your form should capture students and people(make use of radio buttons),textboxes for capturing amount of tucket , and the respective discount(s). ) you are however not limited or entirely guided by the hint. [15]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the html and js code:

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Airplane Ticket</title>
</head>
<body>
<form id="fareform" onsubmit="CalculateFare(event)">
<label for="tickets">Number of tickets to purchase: </label>
<input type="number" name="Tickets" value="" id="tickets" required>
<br><br>
<label for="date">Date of journey:</label>
<input type="date" id="date" name="Date" required>
<br><br>
You Are A:<br>
<input type="radio" id="student" name="Type" value="s">
<label for="male">Student</label><br>
<input type="radio" id="person" name="Type" value="n" checked>
<label for="female">Not a student</label>
<br><br>
<input type="submit" name="Submit" value="submit">
</form>
<h1>Your Ticket Fare is: </h1><h1 id="farevalue">0</h1>
</body>
<script type="text/javascript">
var today = new Date().toISOString().split('T')[0];
document.getElementsByName("Date")[0].setAttribute('min', today);
  
CalculateFare = function(event) {
var ticket = document.getElementById("tickets").value;
if(ticket <= 0){
alert("Please Enter Correct Positive Number Of Tickets.")
}else{
var date = document.getElementById("date").value;
var diff = ((new Date(date)).getTime() - (new Date()).getTime()) / (1000 * 3600 * 24);
var discount = 0;
if(diff>=30){
discount = 20;
}
if(document.getElementById("student").checked){
discount = discount + 30;
}
document.getElementById("farevalue").innerHTML = 8 * ticket * (100 - discount);
}
event.preventDefault();
}
</script>
</html>

Add a comment
Know the answer?
Add Answer to:
The full price of a plane ticket is 800$ for example, but discounts are applied to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Must be done in C# please! Thanks! In this assignment you will create a program named...

    Must be done in C# please! Thanks! In this assignment you will create a program named Test Scores that displays the average of all tests; average midterm score; average final score; and displays the midterm or final score of a particular student. Create a class level two dimensional integer array named Grades initialized with the following data: 897 242 301 987 116 450 865 128 992 109 88 75 94 70 90 87 81 79 97 79 78 80 92...

  • Project: Using Java API Classes Page 3 of 5 SpaceTicket.java Requirements: The purpose of this program is accept coded...

    Project: Using Java API Classes Page 3 of 5 SpaceTicket.java Requirements: The purpose of this program is accept coded space ticket information as input that includes the ticket price, category, time, date, and seat, followed by the description of the travel. Note that the eight digits for price have an implied decimal point. The program should then print the ticket information including the actual cost, which is the price with discount applied as appropriate: 25% for a student ticket (s),...

  • 1. When conducting a survey, it is important to use a random sample: to get a...

    1. When conducting a survey, it is important to use a random sample: to get a significant result. to avoid bias and to get a representative sample. so that we can make causal conclusions. to ensure truthful answers to the survey's questions. none of the above. 2. In order to obtain a sample of undergraduate students in the United States, a simple random sample of 10 states is selected. From each of the selected states, 10 colleges or universities are...

  • 1. A State issues car license plates with three letters followed by three numbers (for example,...

    1. A State issues car license plates with three letters followed by three numbers (for example, FGH831 or BBB222). How many different license plates are possible? (Note that letters or numbers may repeat in the license plate. Hint: Use the Fundamental Counting Rule for this question.) There are five students who are interested in presenting their final project to the class, but there is only time for three presentations. The five students are Amy, Bob, Chun, Dan and Ed. 2....

  • A State issues car license plates with three letters followed by three numbers (for example, FGH831...

    A State issues car license plates with three letters followed by three numbers (for example, FGH831 or BBB222). How many different license plates are possible? (Note that letters or numbers may repeat in the license plate. Hint: Use the Fundamental Counting Rule for this question.) There are five students who are interested in presenting their final project to the class, but there is only time for three presentations. The five students are Amy, Bob, Chun, Dan and Ed. List all...

  • These tests are intended for undergraduate students in college or those under 18 years of age....

    These tests are intended for undergraduate students in college or those under 18 years of age. Read these directions carefully! The below test includes 10 questions, randomly selected from a large inventory. Most questions will be different each time you take the test, You must answer at least 9 out of 10 questions correctly to receive your Certificate. You have 40 minutes to complete each test, and you must answer all 10 questions in order to to see your results....

  • 13) The cost the Almy type of market 7) The market is an example of A)...

    13) The cost the Almy type of market 7) The market is an example of A) mattress: a monopoly B) com a perfectly competitive C) car insurance an oligopoly D) cell phone; a perfectly competitive 5) airplane manufacturing a monopolistically competitive 8) What is the difference between perfect competition and monopolistic competition? A) Perfect competition has a large number of small firms while monopolistic competition does not in monopolistic competition, firms produce identical goods, while in perfect competition, firms produce...

  • Physics Lab Assignment This particular discovery is also an example of how those who deserve an...

    Physics Lab Assignment This particular discovery is also an example of how those who deserve an award sadly are not always the ones who receive it. Read the following passage focusing your attention on the scientific procedures and scientific abilities you have been developing throughout the course. The discovery of pulsars –rotating neutron stars that generate regular pulses of radiation at their spin rate- was fortuitous. A group of astrophysicists from Cambridge University lead by Anthony Hewish was looking for...

  • Hello, this is my code. moest of the things works but when select the price, i...

    Hello, this is my code. moest of the things works but when select the price, i just dont get my total. can someone help me out . thank you My queshion is also here The page will simulate the site for a Chicago-based small bus line that travels to St Louis, Milwaukee, and Detroit. Here are the requirements: The home page (i.e. the main page) should simply be the heading, image, and slogan of the site.  The home page should NOT...

  • Mike is selling his vacation cabin on the lake. His asking price is $150,000 cash, but...

    Mike is selling his vacation cabin on the lake. His asking price is $150,000 cash, but so far no one has offered to meet his terms. He expressed a willingness to finance the purchase himself and suddenly there were five offers on the table from Andy, Bill, Charlie, Dan, and Earl. Andy offered to pay him $60,000 today and to then make quarterly payments of $10,000 each quarter over the next three years. Bill has offered $90,000 today plus another...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT