Question

In: Computer Science

IM GETTING A ERROR MESSAGE : if rentalCode == 'W' and averageMiles <= 900: mileCharge =...

IM GETTING A ERROR MESSAGE :

if rentalCode == 'W' and averageMiles <= 900:
mileCharge = weeksRented * 100.00
else:

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:

    odoStart = 1234
    odoEnd = 2222
    

    Collect Customer Data - Part 2 - Feedback Link

    IF you would like some constructive feedback on your assignment before you submit for a grade, press the Help Me! button below.

    Help Me!

    Customer Data Check 2

    In your rental_car.py file, add code to print out the two new variables you have collected input for:
    odoStart
    odoEnd
    totalMiles

    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)
      1. Test your code.
      2. 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":
        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":
        averageDayMiles = totalMiles/rentalPeriod
        if averageDayMiles <= 100:
        extraMiles == 0
        # ii)   If averageDayMiles is above the 100 mile per day
        # limit:
        # (1)   calculate extraMiles (averageDayMiles - 100)
        if totalMiles >= 100 and rentalCode == 'D':
        # (2)   mileCharge is the charge for extraMiles,
        mileCharge = totalMiles * int(rentalPeriod) *0.25   
        #c)   Code 'W' (weekly) mileage charge: no charge if the
        # average number of miles driven per week is
        # 900 miles or less;
        if rentalCode == 'W' and averageMiles <= 900:
        mileCharge = weeksRented * 100.00
        else:
        mileCharge = 0
        # 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
        if rentalCode == 'W' and averageMiles >= 900:
        mileCharge = weeksRented * 100.00
        else:
        print('Charges : ${}'.format(mileCharge))

Solutions

Expert Solution

If you have any doubts, please give me comment...

import sys

'''

Section 1: Collect customer input

'''

#Add customer input 1 here, rentalCode = ?

rentalCode = input ("(B)udget, (D)aily, or (W)eekly rental? ")

print(rentalCode)

if rentalCode == "B" or rentalCode == "D":

    rentalPeriod = int(input("Number of Days Rented: "))

else:

    rentalPeriod = int(input("Number of Weeks Rented: "))

if rentalCode == "B":

    baseCharge= rentalPeriod * 40.00

elif rentalCode == "D":

    baseCharge= rentalPeriod * 60.00

else:

    baseCharge= rentalPeriod * 190.00

#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 = int(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 = int(input("Ending Odometer Reading: "))

#c) Calculate total miles

totalMiles = int(odoEnd) - int(odoStart)

#Print odoStart, odoEnd and totalMiles

print (odoStart)

print (odoEnd)

print (totalMiles)

averageDayMiles = 0

# 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" :

    mileCharge = totalMiles*0.25

    print("Charges: ${}".format(mileCharge))

#b)   Code 'D' (daily) mileage charge: no charge if the average

# number of miles driven per day is 100 miles or less;

elif rentalCode == "D":

    # 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,

    averageDayMiles = totalMiles/rentalPeriod

    if averageDayMiles <=100 :

        extraMiles = 0

    else:

        extraMiles = float(averageDayMiles - 100)

    mileCharge = float(extraMiles*0.25)

    print("Charges: ${}".format(mileCharge))

#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

elif rentalCode == 'W':

    averageWeeklyMiles = totalMiles/rentalPeriod

    if averageWeeklyMiles <=900:

        extraMiles = 0

    else:

        extraMiles = float(totalMiles - 900)

    mileCharge += float(extraMiles*100)

    print("Charges: ${}".format(mileCharge))

else:

    print("Invalid rental code")


Related Solutions

Im getting an error on the Player.h class. Error reads expected initializer before player. I have...
Im getting an error on the Player.h class. Error reads expected initializer before player. I have put a comment by the line with the error. sample out put is Welcome to Rock Paper Scissors You played: paper Computer played: paper It's a tie Player.h #include<string> using namespace std; class Player{    private:        int play;//variable        public:    string getPlay();//variables    void setPlay(string play);    void setPlay(int play); } string Player = getPlay(){//error    if(this.play == 1){   ...
I'm getting an error message with this code and I don't know how to fix it...
I'm getting an error message with this code and I don't know how to fix it The ones highlighted give me error message both having to deal Scanner input string being converted to an int. I tried changing the input variable to inputText because the user will input a number and not a character or any words. So what can I do to deal with this import java.util.Scanner; public class Project4 { /** * @param args the command line arguments...
Getting an error: ERROR: is/2: Arguments are not sufficiently instantiated /* *Go predicate * Call as...
Getting an error: ERROR: is/2: Arguments are not sufficiently instantiated /* *Go predicate * Call as follows: * ?- go(state(3,3,w),state(0,0,e)). */ go(Start,Goal) :-    empty_stack(Empty_visited_stack),    stack(Start,Empty_visited_stack,Visited_stack),    path(Start,Goal,Visited_stack). /* * path predicates */ path(Goal,Goal,Visited_stack) :-    write('Solution path is:' ), nl,    write(Visited_stack). path(State,Goal,Visited_stack) :-    move(State,Next_state),    not(member_stack(Next_state,Visited_stack)),    stack(Next_state,Visited_stack,New_visited_stack),    path(Next_state,Goal,New_visited_stack). safe(M1,C1) :-    (M1 =< C1; C1 = 0),     M2 is 3-M1, C2 is 3-C1,     (M2 =< C2; C2 = 0). /* * move...
What caused the following error message to appear in Microsoft access do not merely state the name of the error indicate why the error occurred and what the user was doing when this message appeared?
What caused the following error message to appear in Microsoft access do not merely state the name of the error indicate why the error occurred and what the user was doing when this message appeared?
Why am I getting this error using 000webhost , but I do not get this error...
Why am I getting this error using 000webhost , but I do not get this error running XAMPP? Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd2/006/14881006/public_html/test/index.php:1) in /storage/ssd2/006/14881006/public_html/test/index.php on line 8 Code is below. ******************************************************************************************************************** <!DOCTYPE html> <?php    //Determine if the submit button has been clicked to set the cookie name and value    if (isset($_POST['name'])){            $cookie_name = $_POST['name'];            $cookie_value = $_POST['value'];            setcookie($cookie_name, $cookie_value,...
for question 3 im getting 96.234 sec but it says its wrong but close to the...
for question 3 im getting 96.234 sec but it says its wrong but close to the answer. for activation energy.. i get 24.6 kj/mol but its wrong 3) You mix together in the proper manner the following VOLUMES: 0.0100 M Potassium iodide...14.7 mL 0.0010 M Sodium thiosulfate...5.6 mL Distilled water...22.7 mL 0.0400 M Potassium Bromate...11.7 mL 0.100 M Hydrochloric acid...5.6 mL Using the rate constant and rate equation from problem 2), exponent c is 1.92 exponent constant K 4.7125 CALCULATE...
BALANCING: Na2SO3 (aq) + H2SO4(aq) PLEASE explain your answer. im fine w balancing, im just confused...
BALANCING: Na2SO3 (aq) + H2SO4(aq) PLEASE explain your answer. im fine w balancing, im just confused with trying to find the reaction formula. i know the answer, i need to know HOW you got it (ive looked everywhere and cant find an explanation for why you get the H20 and the SO2 in the answer)
A normalized message signal has a bandwidth of W = 10 KHz and a power of...
A normalized message signal has a bandwidth of W = 10 KHz and a power of Pm= 0.75 . It is required to transmit this signal via a channel with an available bandwidth of 80 KHz and attenuation of 50 dB. The channel noise is additive and white with a power-spectral density of N0/2 = 10^(-10) watts/Hz. A frequency-modulation scheme, with no pre-emphasis/de-emphasis filtering, has been proposed for this purpose. 1. If it is desirable to have an SNR of...
Every answer shown for this question appears to be giving an error message or locking the...
Every answer shown for this question appears to be giving an error message or locking the database or telling me there is an operational error or undefined parameter of some sort. Here is the question. This is for Python3 Define the Artist class in Artist.py with a constructor to initialize an artist's information. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. Define the Artwork class in Artwork.py with...
I keep getting the same error Error Code: 1822. Failed to add the foreign key constraint....
I keep getting the same error Error Code: 1822. Failed to add the foreign key constraint. Missing index for constraint 'test_ibfk_5' in the referenced table 'appointment', can you please tell me what is wrong with my code: -- Table III: Appointment = (site_name [fk7], date, time) -- fk7: site_name -> Site.site_name DROP TABLE IF EXISTS appointment; CREATE TABLE appointment (    appt_site VARCHAR(100) NOT NULL, appt_date DATE NOT NULL, appt_time TIME NOT NULL, PRIMARY KEY (appt_date, appt_time), FOREIGN KEY (appt_site)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT