Simple python

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter3: Performing Calculations With Formulas And Functions
Section: Chapter Questions
Problem 4.9CP
icon
Related questions
Question
100%
Simple python
The program should first calculate the distance from TubWub headquarters to the event, using the follow process to calculate
the approximate distance between two locations in kilometers:
1. Calculate ALat, the difference between the latitudes. Multiply by 111.048 to convert the degree difference to kilometers.
2. Calculate ALong, the difference between the longitudes. Multiply by 84.515 to convert the degree difference to
kilometers.
3. The distance between the locations is then found (ALat)²2 + (ALong)².
(We're assuming that the event entered is in or close to New York City, so that we can treat the Earth as essentially flat.)
The program should then decide how many tickets to buy based on the following rules: no tickets should be bought if the
event is more than 3 kilometers; no tickets should be purchased if the event is not "hot"; and if neither of the above applies,
the number of tickets purchased should be the greatest integer such that the total price of the tickets does not exceed 150.00
dollars.
A sample run should look like:
Enter latitude of event: 40.768
Enter longitude of event: -73.972
Price per ticket: 60
Is it hot?: y
Distance = 3.240166507609296
Buy 0 tickets
Here, the four bits following the colons (40.768, -73.972, 40, y) are entered by the user; everything else is printed out by the
program. This example prints Buy 0 tickets because, while the event is "hot", the distance is greater than 3 kilometers
away. Another sample run might look like:
Enter latitude of restaurant: 40.742
Enter longitude of restaurant: -73.983
Price per ticket: 41.32
Is it hot?: y
Distance = 0.2069418381770326
Buy 3 tickets
Since this event is so close and it is hot, you purchase tickets, and since 3. (41.32) < 150.00 while 4 (41.32) > 150.00, three
tickets are the most that can be afforded. (Hint: math.floor(), which gives the integer part of a positive number, may be
helpful.)
Be sure to test your program with other combinations, too!
Specifications: your program must
ask for and accept a latitude, a longitude, a price per ticket, and the answer to the question "Is it hot?" (you may
assume that the user cooperates, by entering a positive numerical value for the price, and either lowercase y or n for the
"hot" question).
• print out the distance (in kilometers) of the restaurant from TubWub headquarters at latitude 40.740230°, longitude
-73.983766°.
display a decision about how many tickets to purchase, based on the criteria that: no tickets should be bought if the
event is more than 3 kilometers from headquarters; no tickets should be purchased if the event is not "hot"; and if
neither of the above applies, the number of tickets purchased should be the greatest integer such that the total price of
the tickets does not exceed 150.00 dollars.
Transcribed Image Text:The program should first calculate the distance from TubWub headquarters to the event, using the follow process to calculate the approximate distance between two locations in kilometers: 1. Calculate ALat, the difference between the latitudes. Multiply by 111.048 to convert the degree difference to kilometers. 2. Calculate ALong, the difference between the longitudes. Multiply by 84.515 to convert the degree difference to kilometers. 3. The distance between the locations is then found (ALat)²2 + (ALong)². (We're assuming that the event entered is in or close to New York City, so that we can treat the Earth as essentially flat.) The program should then decide how many tickets to buy based on the following rules: no tickets should be bought if the event is more than 3 kilometers; no tickets should be purchased if the event is not "hot"; and if neither of the above applies, the number of tickets purchased should be the greatest integer such that the total price of the tickets does not exceed 150.00 dollars. A sample run should look like: Enter latitude of event: 40.768 Enter longitude of event: -73.972 Price per ticket: 60 Is it hot?: y Distance = 3.240166507609296 Buy 0 tickets Here, the four bits following the colons (40.768, -73.972, 40, y) are entered by the user; everything else is printed out by the program. This example prints Buy 0 tickets because, while the event is "hot", the distance is greater than 3 kilometers away. Another sample run might look like: Enter latitude of restaurant: 40.742 Enter longitude of restaurant: -73.983 Price per ticket: 41.32 Is it hot?: y Distance = 0.2069418381770326 Buy 3 tickets Since this event is so close and it is hot, you purchase tickets, and since 3. (41.32) < 150.00 while 4 (41.32) > 150.00, three tickets are the most that can be afforded. (Hint: math.floor(), which gives the integer part of a positive number, may be helpful.) Be sure to test your program with other combinations, too! Specifications: your program must ask for and accept a latitude, a longitude, a price per ticket, and the answer to the question "Is it hot?" (you may assume that the user cooperates, by entering a positive numerical value for the price, and either lowercase y or n for the "hot" question). • print out the distance (in kilometers) of the restaurant from TubWub headquarters at latitude 40.740230°, longitude -73.983766°. display a decision about how many tickets to purchase, based on the criteria that: no tickets should be bought if the event is more than 3 kilometers from headquarters; no tickets should be purchased if the event is not "hot"; and if neither of the above applies, the number of tickets purchased should be the greatest integer such that the total price of the tickets does not exceed 150.00 dollars.
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage