Question

In: Computer Science

Collect Customer Data - Part 2 Collect Mileage information: Prompt: "Starting Odometer Reading:\n" Variable: odoStart =...

Collect Customer Data - Part 2

  1. Collect Mileage information:

    Prompt: "Starting Odometer Reading:\n"

    Variable: odoStart = ?

    Prompt: "Ending Odometer Reading:\n"

    Variable: odoEnd = ?

    Add code to PRINT odoStart and odoEnd variables as well as the totalMiles to check your work.

    The following data will be used as input in the test:

    1. Prompt the user to input the starting odometer reading (expect type int from the user)
    2. Prompt the user to input the ending odometer reading (expect type int from the user)
    3. Test your code.

import sys
'''
Section 1: Collect customer input
'''
#Add customer input 1 here, rentalCode = ?

#Collect Customer Data - Part 2

#4)Collect Mileage information:
#a)   Prompt the user to input the starting odometer reading and store it as the variable odoStart

#Prompt -->"Starting Odometer Reading:\n"
# odoStart = ?

#b)   Prompt the user to input the ending odometer reading and store it as the variable odoEnd

#Prompt -->"Ending Odometer Reading:"
# odoEnd = ?

#c) Calculate total miles

#Print odoStart, odoEnd and totalMiles


# Calculate Charges 2

##   Calculate the mileage charge and store it as
# the variable mileCharge:

#a)   Code 'B' (budget) mileage charge: $0.25 for each mile driven

#b)   Code 'D' (daily) mileage charge: no charge if the average
# number of miles driven per day is 100 miles or less;
# i)   Calculate the averageDayMiles (totalMiles/rentalPeriod)

# ii)   If averageDayMiles is above the 100 mile per day
# limit:
# (1)   calculate extraMiles (averageDayMiles - 100)
# (2)   mileCharge is the charge for extraMiles,
# $0.25 for each mile


#c)   Code 'W' (weekly) mileage charge: no charge if the
# average number of miles driven per week is
# 900 miles or less;

# i)   Calculate the averageWeekMiles (totalMiles/ rentalPeriod)

# ii)   mileCharge is $100.00 per week if the average number of miles driven per week exceeds 900 miles

Im getting a Error on my Script at line 55:

LAST RUN on 9/14/2019, 8:44:31 AM

 

Check 1 failed

Output:

File "rental_car-customer-data-2.py", line 55 elif rentalCode == 'W' or rentalCode=='w': ^ SyntaxError: invalid syntax

Expected:

Starting Odometer Reading: Ending Odometer Reading: 1234 2222 988

My Script:

import sys
'''
Section 1: Collect customer input
'''
#Add customer input 1 here, rentalCode = ?
rentalCode = input("(B)udget, (D)aily, or (W)eekly rental?\n")
print (rentalCode)
#Collect Customer Data - Part 2

#4)Collect Mileage information:
#a)   Prompt the user to input the starting odometer reading and store it as the variable odoStart

#Prompt -->"Starting Odometer Reading:\n"
# odoStart = ?
odoStart = input('Starting Odometer Reading: ')
#b)   Prompt the user to input the ending odometer reading and store it as the variable odoEnd

#Prompt -->"Ending Odometer Reading:"
# odoEnd = ?
odoEnd = input('Ending Odometer Reading: ')
#c) Calculate total miles
totalMiles = int(odoEnd) - int(odoStart)
#Print odoStart, odoEnd and totalMiles
print (odoStart)
print (odoEnd)
print (totalMiles)

# Calculate Charges 2

##   Calculate the mileage charge and store it as
# the variable mileCharge:

#a)   Code 'B' (budget) mileage charge: $0.25 for each mile driven
if rentalCode == "B" or rentalCode=='b':
mileCharge = totalMiles * 0.25
#b)   Code 'D' (daily) mileage charge: no charge if the average
# number of miles driven per day is 100 miles or less;
# i)   Calculate the averageDayMiles (totalMiles/rentalPeriod)
elif rentalCode == "D" or rentalCode=='d':
rentalPeriod = int(input('Enter days rented: '))
averageDayMiles = totalMiles/rentalPeriod
if averageDayMiles <= 100:
mileCharge=0
# ii)   If averageDayMiles is above the 100 mile per day
# limit:
# (1)   calculate extraMiles (averageDayMiles - 100)
else:
# (2)   mileCharge is the charge for extraMiles,
# $0.25 for each mile
mileCharge = (averageDayMiles-100) *0.25

#c)   Code 'W' (weekly) mileage charge: no charge if the
# average number of miles driven per week is
# 900 miles or less;
elif rentalCode == 'W' or rentalCode=='w':
rentalWeek = int(input('Enter rental week: '))
averageWeekMiles = totalMiles / rentalWeek
if averageWeekMiles<=900:
mileCharge=0
else:
mileCharge=100*rentalWeek
print('Charges : ${}'.format(mileCharge))
# i)   Calculate the averageWeekMiles (totalMiles/ rentalPeriod)

# ii)   mileCharge is $100.00 per week if the average number of miles driven per week exceeds 900 miles


Solutions

Expert Solution

Thanks for the question.

Below is the code you will be needing  Let me know if you have any doubts or if you need anything to change.

Thank You !!

===========================================================================

def compute_bill(code,days,start_reading,end_reading):
    distance=getDistance(start_reading,end_reading)
    if code=='B':
        return 40*days + (distance)*0.25
    elif code=='D':
        average= (distance)/days
        if average<=100:
            return 60*days
        else:
            print(distance)
            return 60*days+ 0.25*(distance-days*100)
    elif code=='W':
        average_weekly=(distance)*7/days
        if average_weekly<=900:
            return 190*(days)/7
        elif average_weekly<=1500:
            return 100*(days)/7
        else:
            return 200*days/7 + (average_weekly-1500)*0.25
    else:
        return 0

def getDistance(start_reading,end_reading):
    if start_reading > end_reading:
        distance = (1+(999999 - start_reading) + end_reading) / 10.0
    else:
        distance = end_reading - start_reading
    distance /= 10.0
    return distance


def printInstructions():
    print('Welcome to car rentals.')
    print('At the prompts, please enter the following:')
    print('Customer\'s classification code (a character: BDW)')
    print('Number of days the vehicle was rented (int)')
    print('Odometer reading at the start of the rental period (int)')
    print('Odometer reading at the end of the rental period (int)')
def main():
    #printInstructions()
    while True:
        answer=input('Would you like to continue (Y/N)? ')
        if answer=='Y':
            while True:
                code = input('Customer code (BDW): ').upper()
                if code not in ['B','D','W']:
                    print('*** Invalid customer code. Try again. ***')
                else:
                    break
                
            days=int(input("Number of days: "))
            start_reading=int(input('Odometer reading at the start: '))
            end_reading=int(input('Odometer reading at the end: '))
            bill=compute_bill(code,days,start_reading,end_reading)
            print('Customer summary:')
            print('classification code: {}'.format(code))
            print('rental period (days): {}'.format(days))
            print('odometer reading at start:  {}'.format(start_reading))
            print('odometer reading at end:     {}'.format(end_reading))
            print('number of miles driven:      {}'.format(getDistance(start_reading,end_reading)))
            print('amount due: $ {0:.2f}'.format(bill))
        else:
            print('Thank you for your loyalty.')
            break
main()

=====================================================================


Related Solutions

Print greeting Prompt the user for starting odometer reading Use a while loop to validate that...
Print greeting Prompt the user for starting odometer reading Use a while loop to validate that starting odometer reading is a positive number. Initialize variables: last odometer reading, current odometer reading, leg number, total fuel, moreInput While moreInput == ‘y’ Prompt the user for new odometer reading and fuel consumed If fuel is positive and new odometer reading > last odometer reading: Calculate MPG for this leg using mpg = (new odometer – last odometer) / fuel Print MPG for...
The following data give the odometer mileage (rounded to the nearest thousand miles) for all 20...
The following data give the odometer mileage (rounded to the nearest thousand miles) for all 20 cars that are for sale at a dealership. 61 88 58 83 71 40 27 38 52 43 27 40 90 43 95 35 28 47 88 76 a. Calculate the values of the three quartiles and the interquartile range. Q1 = Q2 = Q3 = IQR = b. Find the approximate value of the 19th percentile. c. Calculate the percentile rank of 71....
When we collect information for research purposes, we collect raw data. This data is great, but...
When we collect information for research purposes, we collect raw data. This data is great, but doesn't always end up meaning a whole lot until we draw some conclusions, organize it and look for patterns. When we organize it a bit, it then becomes what we can consider information. Information is a lot more useful than raw data. In 200 words Do any of you collect data at work? How can you best take raw data and ensure that it...
Part I: Prompt the user for a single string and store it in a variable named...
Part I: Prompt the user for a single string and store it in a variable named userString. a. Use a for loop to print the string, char by char, with a dash '-' char between each. b. Use a for loop to print the string backwards, char by char, with a dash '-' char between each. Part II: Create an array of 5 strings named userStrings. Use a generalized array size. const int n = 5; string userStrings[n]; a. Populate...
AIS: In the U.S., organizations are allowed to collect personal information about customers unless the customer...
AIS: In the U.S., organizations are allowed to collect personal information about customers unless the customer explicitly objects (called opt-out). In contrast, the default policy in EU is opt-in, meaning that organizations cannot collect personally identifying information unless customers explicitly give them permission to do so. What are the advantages and disadvantages to the opt-in versus the opt-out approaches?
For this part of the project, you’ll collect data on various measure of confidence from the...
For this part of the project, you’ll collect data on various measure of confidence from the FRED website Figure 10 – University of Michigan: Consumer Sentiment (UMCSENT), last year Figure 11 – S&P 500 (SP500), last year Figure 12 – St. Louis Fed Financial Stress Index (STLFSI), last year 1. In your own words, briefly describe what each of the three indices measure. Why are these considered an indicator of the economy’s “health”? 2. How have these indices changed over...
For this part of the project, you’ll collect data on various measure of confidence from the...
For this part of the project, you’ll collect data on various measure of confidence from the FRED website. University of Michigan: Consumer Sentiment (UMCSENT), last year S&P 500 (SP500), last year St. Louis Fed Financial Stress Index (STLFSI), last year 1. In your own words, briefly describe what each of the three indices measure. Why are these considered an indicator of the economy’s “health”? 2. How have these indices changed over the past year? Do you think consumers and firms...
QUESTION 80 A(n) mixed expense is an expense that is part variable and part fixed. _________________________...
QUESTION 80 A(n) mixed expense is an expense that is part variable and part fixed. _________________________ True False QUESTION 81 All three expense types can be classified as _______. a. mixed, fixed, and CVP b. variable, fixed, and cost-based c. variable, fixed, and mixed d. asset-based, fixed, and mixed QUESTION 82 Aside from Solver, other Excel _______ provide the ability to perform statistical analyses, generate business reports, and retrieve financial data from the Internet. a. constraint applications b. parameters c....
For this part of the project, you’ll collect data on real GDP and potential GDP measures...
For this part of the project, you’ll collect data on real GDP and potential GDP measures from the FRED website.   – Real GDP (GDPC1) AND Real Potential GDP (GDPPOT), 2007 – current year After that, answer all these questions. 1. What is the conceptual difference between real GDP and potential GDP? In terms of the economy using their resources, what does it mean if real GDP is less than potential GDP? What does it mean if real GDP is greater...
PART 2 Each week, you will be asked to respond to the prompt or prompts in...
PART 2 Each week, you will be asked to respond to the prompt or prompts in the discussion forum. Your initial post should be 75-150 words in length, and is due on Sunday. By Tuesday, you should respond to two additional posts from your peers. Discussion B: I have found that learning is increased when students practice going in both directions; formal to informal, and informal to formal. The primary focus is the Pathophysiology in this discussion. Anatomy and Physiology...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT