Problems finding out total sum using data structures and arrays
<p>I have this code that has several funtions and am almost done, I just am having trouble finding the rental cost on my program.
My program reads a text file of cars and the rental cost as shown here:</p>

<pre><code>2014 Toyota Tacoma 115.12 1
2012 Honda CRV 85.10 0
2015 Ford Fusion 90.89 0
2013 GMC Yukon 110.43 0
2009 Dodge Neon 45.25 1
2011 Toyota Rav4 65.02 1
2012 Mazda CX5 86.75 1
2016 Subaru Outback 71.27 0
2015 Ford F150 200.83 1
2010 Toyota Corolla 50.36 1
</code></pre>

<p>The float character is the price ( rental cost )</p>

<p>However I want the user to input the car number ( 1-10) choose how many days and output the rental cost. I am just having trouble how it would read the input of the car the user wants. This is my main code, but what I need is to tell if case 3 needs work.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;

using namespace std;

struct car {
    int year;
    char make[10];
    char model[10];
    float price;
    int available;

} ;

void menu();

// Main Function
int main ()
{
// declare variables
int carAmount = 10;
int choice;
car carLib[carAmount];
char filename[10];
ifstream carInData;
float mostExpensive = 0;
int MostExpensiveIndex;
int count = 0;
int days;
int rentalCost = 0;
bool menu1 = false;

    //prompt user for input file
    cout &lt;&lt; " Enter file name: ";
    cin &gt;&gt; filename;

    // Start loop menu
    while(menu1 = true){

    menu();

    carInData.open(filename);

    cin &gt;&gt; choice;

    if (carInData.is_open()) {
    // read list of names into array


       for (; count &lt; carAmount; count++) {

        carInData &gt;&gt; carLib[count].year &gt;&gt; carLib[count].make &gt;&gt; carLib[count].model &gt;&gt; carLib[count].price &gt;&gt; carLib[count].available;

        }
    }

    switch (choice) {

   // Case 1 closes menu
    case 1:

    return 0;
    break;

    // Case 2 displays if car is available if 1, unavailable if 0
    case 2:

    // itterate through car array
    for(count = 0; count &lt; carAmount; count++){

    // Displays if car is available or not 
    if (carLib[count].available == 1)
        cout &lt;&lt; " Available ";
    else
        cout &lt;&lt; " Unavailable ";

    // Display Cars
    cout &lt;&lt; carLib[count].year &lt;&lt; " " &lt;&lt; carLib[count].make &lt;&lt; " " &lt;&lt; carLib[count].model &lt;&lt; " " &lt;&lt; carLib[count].price &lt;&lt; "  " &lt;&lt; "\n";
    }
    break;

    // Display only available cars
    case 3:

    // itterate through car array
    for(count = 0; count &lt; carAmount; count++){

    // Displays only available cars
    if (carLib[count].available == 1){
        cout &lt;&lt; " Available ";

    // Display Cars
    cout &lt;&lt; carLib[count].year &lt;&lt; " " &lt;&lt; carLib[count].make &lt;&lt; " " &lt;&lt; carLib[count].model &lt;&lt; " " &lt;&lt; carLib[count].price &lt;&lt; "  " &lt;&lt; "\n";
      }
    }
    break;


    // Calculates  rental cost
    case 4:
    cout &lt;&lt; " Enter car number and how many days " &lt;&lt; "\n";
    cout &lt;&lt; " Days: ";
    cin &gt;&gt; days;
    cout &lt;&lt; "\n" &lt;&lt; "Car: ";
    cin &gt;&gt; carLib[count].price;
    rentalCost += days*count;

    cout &lt;&lt; " Rental Cost for " &lt;&lt; days &lt;&lt; " days is " &lt;&lt; rentalCost &lt;&lt; "\n";
    break;

    // Finds most expensive car
    case 5:

    MostExpensiveIndex = count;
    for (size_t carIndex = 0; carIndex &lt; carAmount; ++carIndex) {

        if (carLib[carIndex].price &lt;= mostExpensive) continue;
        mostExpensive = carLib[carIndex].price;
        MostExpensiveIndex = carIndex;

    }

    const car &amp; carI = carLib[MostExpensiveIndex];

    cout &lt;&lt; " Most Expensive car is: " &lt;&lt; " " &lt;&lt; carI.year &lt;&lt; " " &lt;&lt; carI.make &lt;&lt; " " &lt;&lt;  carI.model &lt;&lt; " "  &lt;&lt; carI.price &lt;&lt; "\n";

    break;



      }

    }

    return 0;
}


void menu()
{
    cout &lt;&lt; " 1 - Exit program.\n";
    cout &lt;&lt; " 2 - Show Cars\n"; 
    cout &lt;&lt; " 3 - Show only available cars.\n";
    cout &lt;&lt; " 4 - Rental Cost\n";
    cout &lt;&lt; " 5 - Most Expensive Car\n";
}  
</code></pre>