While Loop problem

So I'm trying to make this program loop that the initial total number of cars is 0, and the number of cars that will be left on the lot each day will be the total minus the rented cars. It should loop so that it continues to ask for rented cars and the rental cost, so after the first day the new total would be the lot cars, so it would continue each day until the number of cars left is obviously 0 or the number of cars asked for is more than the amount left, anyone can offer any help to tweak this code?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  #include <iostream>

using namespace std;
struct Rental
{
    float rented_cars;
    float rental_cost;
    float daily_earn;
    int lot_cars;
    int total_cars;
};
    float printmsg(Rental R)
    {
    cout<<"The money earned each day = "<<R.daily_earn<<endl;
    cout<<"The number of cars left on the lot = "<<R.lot_cars<<endl;
    }
int main ()
{
    Rental A;
    cout<<"Enter the total number of cars"<<endl;
    cin>>A.total_cars;
    while(A.total_cars>0)
    {
    A.daily_earn = A.rented_cars*A.rental_cost;
    A.lot_cars = A.total_cars-A.rented_cars;
    A.lot_cars = A.total_cars;
    cout<<"Enter the number of cars rented, then the cost per rental"<<endl;
    cin>>A.rented_cars>>A.rental_cost;
    printmsg(Rental (A));

    }
}

the initial total number of cars is 0

That does not quite make sense. It could make sense if one daily action is buying new cars. I bet there is not.

The total number of cars is usually the sum of rented and "in lot" cars. (Handling demolished and stolen vehicles is extra.)

The basic transactions are renting and returning. When you rent a car out, the lot decreases by one, but the number of rented cars increases by one. Similarly, the return increases the lot and decreases the amount of rented.

Your business seems to rent cars for eternity and go bankrupt when all the cars are out, i.e. when you reach maximum revenue level (which would continue foreever).
that was actually a mistake it should've been 100*. I understand the concept but I don't know how to translate it to code.
Topic archived. No new replies allowed.