Program has to be on python for beginners
Program approach:
- Declare basic price.
- Declare basic price for Frederick.
- Declare senior citizens discount.
- Declare price for children.
- Request county name and from user.
- Use if statement for age validation.
- Use if statement for age is less than 6.
- Use if statement to compare county name with FREDERICK.
- Compute price for senior citizens by using if statement.
- Print fair price.
The following program is written in python 3.
Program:
#declare basic price
basicPrice=40
#declare basic price for frederick
basicPriceFrederick=35
#declare senior citizens discount
seniorCitizensDiscount=0.5
#declare price for children
childrenPrice=0
#request county name from user
countyName=input('Enter county name: ')
#request age from user
age=int(input('Enter age: '))
#if statement age validation
if age<0 or age>110:
#print message
print("The inputted age is a not valid age.")
#else statement
else:
#if statement for age is less than 6
if age<6:
#set price to child
price=childrenPrice
#else statement
else:
#if statement to compare county name with FREDERICK
if countyName.upper()=='FREDERICK':
#set price to basic price for FREDERICK
base=basicPriceFrederick
#else statement
else:
#assign basic price in base
base=basicPrice
#if statement for senior citizens
if age>=65:
#compute price for senior citizens
price=base*seniorCitizensDiscount
#else statement
else:
#assign base into price
price=base
#print fair price
print('Your fair price is ${:.2f}'.format(price))
Step by step
Solved in 3 steps with 12 images