Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6255341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:20:52+00:00 2026-05-24T14:20:52+00:00

My professor wants us to write a program without using arrays or vectors like

  • 0

My professor wants us to write a program without using arrays or vectors like this:

Write a program using functions that calculates and prints parking charges for each of the n customers who parked their cars in the garage.

Parking rates:

  • a parking garage charges a $5.00 minimum fee to park for up to five hours.
  • the garage charges an additional $0.50 per hour for each hour or part thereof in the excess of five hours
  • the maximum charge for any given 24hr period is $10.00. Assume that no car parks longer that 24 hours at a time.

You should enter the hours parked for each customer. Your program should print the results in a neat tabular format and should calculate and print the total of your receipts.

The program output should look like this:

car------Hours------Charge

1--------2.00--------$5.00 

2--------5.00--------$5.00

3--------5.30--------$5.50

etc.

total: 3---12.30----$15.50

I only managed to get this far:

include <iostream>
include <conio.h>
include <cmath>
include <iomanip>
using namespace std;
double calculate(double);
int main()
{
    double hours,charge;
    int finish;
    double sumhours;
    sumhours=0;
    finish=0;
    charge=0;
    int cars;
    cars=0;

    do
    {
        cout<<"Enter the number of hours the vehicle has been parked: "<<endl;
        cin>>hours;
        cars++;
        sumhours+=hours;
        finish=cin.get();
        if(hours>24)
        {
            cout<<"enter a time below 24hrs."<<endl;
            cars--; 
            sumhours=sumhours-hours;
        }
    }
        while(finish!=EOF);

        double total=calculate(hours);
        cout<<total<<": "<<(cars-1)<<": "<<sumhours;


    while(!_kbhit());
    return 0;
}

double calculate(double time)
{
    double calculate=0;
    double fees;

    if(time<=5)
        return 5;
     if(time>15)
        return 10;

     time=ceil(time);
     fees=5+(.5*(time-5));

    return calculate;

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:20:53+00:00Added an answer on May 24, 2026 at 2:20 pm

    On every iteration, generate the relevant output, but don’t stream it to std::cout. Instead, stream it to a std::stringstream object. Then, at the end, stream that object to std::cout. The maths can be done simply by maintaining a running accumulation of the input values.

    This, of course, assumes that using a std::stringstream is not considered “cheating” in the context of this homework exercise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, for a homework assignment my professor wants us to write a program in
-- I am to write a program that prompts for N which is number
I have a .plist file that looks like this: <plist version=1.0> <array> <dict> <key>name</key>
So i had to write a program that asks for a user input (which
I am trying to write a simple lock/unlock algorithm that behaves like a mutex
My professor provided me with a file called CursorList.cpp that implements a Cursor Linked
I am taking a class in C++ programming and the professor told us that
Recently for a programming class, we were given the assignment to write a program
I have changed my thread as my last thread also same like that. But
In my assembly language class, our first assignment was to write a program to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.