A bicycle shop in Hyannis rents bicycles by the day at different rates throughout the year, according to the season (see table below).The proprietor also gives a 25% discount if the rental period is greater than 7 days. Renters must also pay a 50$ returnable deposit for each bicycle rented. Write a program to input the season and the number of days of rental and then calculate and display the total charge that includes the deposit. (Use switch statement).
Season Charge
S[spring] $5.00
M[Summer] $7.50
A[Autumn] $3.75
W[Winter] $2.75
#include<iostream.h> #include<conio.h> #include<iomanip> void main() { int days; char season; double bill; cout << "Enter the Season:" << endl <<" S for Spring, M for Summer, A for Autumn, W for Winter: "; cin >> season; cout << "Enter the number of days of Rental: "; cin >> days; switch(season) { case 's': case 'S': if(days>7) bill=((days*5)+50)-(13.75); else bill=(days*5)+50; break; case 'm': case 'M': if(days>7) bill=((days*7.50)+50.00)-(14.375); else bill=(days*7.50)+50.00; break; case 'a': case 'A': if(days>7) bill=((days*3.75)+50.00)-(13.4375); else bill=(days*3.75)+50.00; break; case 'w': case 'W': if(days>7) bill=((days*2.75)+50.00)-(13.1875); else bill=(days*2.75)+50.00; break; default: cout << endl << "\t\t Invalid Character"; } cout << "Your Bill is : " << fixed << setprecision(2) << bill << endl; getche(); }
No comments:
Post a Comment