Answer:
The programming language is not stated;
The program written in C++ is as follows (See Explanation Section for detailed explanation);
#include<iostream>
using namespace std;
int main()
{
int numdays;
cout<<"Number of days of mileage: ";
cin>>numdays;
int miles[numdays];
for(int i=0;i<numdays;i++)
{
cout<<"Miles traveled on day "<<i+1<<": ";
cin>>miles[i];
}
int total = 0;
for(int i=0;i<numdays;i++)
{
total+=miles[i];
}
cout<<"Total mileage traveled: "<<total;
return 0;
}
Explanation:
This line declares the number of days of mileage
int numdays;
This line prompts user for days of mileage
cout<<"Number of days of mileage: ";
This line accepts input from the traveler for days of mileage
cin>>numdays;
This line creates an array
int miles[numdays];
The italicized is an iteration that collects the user input for each day
for(int i=0;i<numdays;i++)
{
cout<<"Miles traveled on day "<<i+1<<": ";
cin>>miles[i];
}
This line initializes variable to 0
int total = 0;
The italicized is an iteration that adds up the mileage traveled by the traveler each day
for(int i=0;i<numdays;i++)
{
total+=miles[i];
}
This line prints the total miles traveled
cout<<"Total mileage traveled: "<<total;