You are on page 1of 1

1

 Home Study tools  My courses  My books Career Life 

Find solutions for your homework Search

home / study / engineering / computer science / computer science questions and answers / write a c++ program to calculate the parking fare for custo…

Question: Write a C++ program to calculate the parking fare for customers… Post a question
Answers from our experts for your tough
homework questions
(3 bookmarks)
Any help with this program? Enter question

Continue to post
16 questions remaining

Snap a photo from your


phone to post a question
We'll send you a one-time download
link

888-888-8888 Text me

By providing your phone number, you agree to receive a one-time


automated text message with a link to get the app. Standard
messaging rates may apply.

My Textbook Solutions

Chemistry... Probability... Vector...

2nd Edition 5th Edition 10th Edition

View all solutions

Show transcribed image text

View comments (2)




Best Answer

jatin89 answered this


Was this answer helpful? 1 0
20 answers

//===========================================================================
=
// Name        : Test.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//===========================================================================
=

#include <iostream>
#include <cmath>
using namespace std;

int main() {

    char type;


    oat inHour,inMinute,outHour,outMinute,totHour,totMinute;
    int charge;

    cout<<"Type of Vehicle (C for Car, B for Bus, T for Truck): ";
    cin>> type;
    cout<<"Hour Vehicle enter lot(0-23)? ";
    cin>> inHour;
    cout<<"Minute Vehicle enter lot(0-60)? ";
    cin>> inMinute;
    cout<<"Hour Vehicle left lot(0-23)? ";
    cin>> outHour;
    cout<<"Minute Vehicle left lot(0-60)? ";
    cin>> outMinute;

    cout<<endl;
    cout<<"PARKING LOT CHARG"<<endl;
    cout<<endl;
    cout<<"Type of Vehicle: ";

    if(type == 'C' || type == 'c')


    {
        cout<<"Car"<<endl;
        charge = 1;
    }
    else if(type == 'T' || type == 't')
    {
        cout<<"Truck"<<endl;
        charge = 2;
    }
    else if(type == 'B' || type == 'b')
    {
        cout<<"Bus"<<endl;
        charge = 3;
    }

    cout<<"Time in: "<<inHour<<":"<<inMinute<<endl;


    cout<<"Time out: "<<outHour<<":"<<outMinute<<endl;
    cout<<"\t ---------"<<endl;

    totHour = outHour-inHour;


    totMinute = fabs(outMinute-inMinute);

    oat tHour;


    if(totMinute <60)
    {
        tHour = 0.5;
    }
    else
    {
        tHour = 1;
    }

    cout<<"Parking Time:"<<totHour<<":"<<totMinute<<endl;


    cout<<"Round Total: "<<totHour+tHour<<endl;
    cout<<"\t ---------"<<endl;

    cout<<"Total Charge: "<<"$"<<(totHour+tHour)*charge<<endl;

    return 0;
}

OUTPUT:

Type of Vehicle (C for Car, B for Bus, T for Truck): c


Hour Vehicle enter lot(0-23)? 14
Minute Vehicle enter lot(0-60)? 35
Hour Vehicle left lot(0-23)? 15
Minute Vehicle left lot(0-60)? 30

PARKING LOT CHARG

Type of Vehicle: Car


Time in: 14:35
Time out: 15:30
    ---------
Parking Time:1:5
Round Total: 1.5
    ---------
Total Charge: $1.5

Comment


More Answers

Eric Cartman answered this


Was this answer helpful? 0 1
1,679 answers

#include <iostream>

using namespace std;

int main ()

char ch;

int H1, H2 , M1, M2, t1, t2 , park, pm , rounded_total , total ;

oat ph;

cout<<"Type of vehicle : ";

cin >> ch;

cout<<"Hour vehicle entered lot (0-23)? ";

cin>>H1;

cout<<"Minute vehicle entered lot (0-60)? ";

cin>>M1;

cout<<"Hour vehicle left lot (0-23)? ";

cin>>H2;

cout<<"Minute vehicle left lot (0-60)? ";

cin>>M2;

t1 = H1*60 + M1;

t2 = H2*60 + M2;

park = t2 - t1;

ph = park /60 ;

pm = park % 60;

if(pm>=30)

rounded_total = ph + 1;

cout<<"-------------------------------\n\n\t\tPARKING LOT CHARGE\n\n";

cout<<"The Type of Vehicle : ";

if(ch == 'T')

cout<<"Truck";

if(ch == 'C')

cout<<"Car";

if(ch == 'B')

cout<<"Bus";

cout<<endl<<endl;

cout<<"TIME IN "<<H1<<":"<<M1<<endl;

cout<<"TIME OUT "<<H2<<":"<<M2<<endl;

cout<<"--------------\n\n";

cout<<"PARKING TIME "<<ph<<":"<<pm<<endl;

if(ch == 'T')

total = rounded_total*2.0;

if(ch == 'B')

total = rounded_total*3.0;

cout<<"ROUNDED TOTAL "<<rounded_total<<endl;

cout<<"\n--------------\n\n";

cout<<"TOTAL CHARGE : $"<<total<<endl;

return 0;

View comments (1)




Practice with similar questions

Q: Write a C++ program to calculate the parking fare for customers who park their cars in a parking lot when the following
information is given: a. A character showing the type of vehicle: C for car, B for bus, and T for truck. b. An integer between
0 and 24 showing the hour the vehicle entered the lot. c. An integer between 0 and 60 showing the minute the vehicle
entered the lot d. An...

A: See answer 100% (1 rating)

Q: Write a C++ program to calculate the parking fare for customers who park their cars in a parking lot when the following
information is given: a. A character showing the type of vehicle: C for car, B for bus, and T for truck. b. An integer between
0 and 24 showing the hour the vehicle entered the lot. c. An integer between 0 and 60 showing the minute the vehicle
entered the lot d. An...

A: See answer

Show more 

Questions viewed by other students

Q: Write a C++ program to calculate the parking fare for customers who park their cars in a parking lot when the following
information is given : a. A character showing the type of vehicle 'C' for car, 'B' for bus, 'T' for truck. b. An integer between 1
-23 showing number of hours the car was parked in the parking lot. C. An integer between 1 - 59 showing number of
minutes the car was...

A: See answer 100% (1 rating)

Q: Write a C++ program to calculate the parking fare for customers who park their cars in a parking lot when the following
information is given: a. A character showing the type of vehicle: C for car, B for bus, and T for truck. b. An integer between
0 and 24 showing the hour the vehicle entered the lot. c. An integer between 0 and 60 showing the minute the vehicle
entered the lot d. An...

A: See answer 100% (1 rating)

Show more 

COMPANY LEGAL & POLICIES CHEGG PRODUCTS AND SERVICES CHEGG NETWORK CUSTOMER SERVICE

About Chegg Advertising Choices Cheap Textbooks Mobile Apps EasyBib Customer Service
Chegg For Good Cookie Notice Chegg Coupon Sell Textbooks Internships.com Give Us Feedback
College Marketing General Policies Chegg Play Solutions Manual Thinkful Help with eTextbooks
Corporate Development Intellectual Property Rights Chegg Study Help Study 101 Help to use EasyBib Plus
Investor Relations Terms of Use College Textbooks Textbook Rental Manage Chegg Study
Jobs Global Privacy Policy eTextbooks Used Textbooks Subscription

Join Our Affiliate Program DO NOT SELL MY INFO Flashcards Digital Access Codes Return Your Books

Media Center Honor Code Learn Chegg Money Textbook Return Policy

Site Map Honor Shield Chegg Math Solver

© 2003-2021 Chegg Inc. All rights reserved.

You might also like