# Thread: Help with a program

1. ## Help with a program

My teacher is asking me "Prompt the user if they'd like to do another cost of commute calculation. If they enter 'Y' or 'y', then repeat; otherwise, print the following and exit the program. "

Code:
```#include <iostream>
using namespace std;

int main(int, char**) {
int milesPerDay;
int daysPerWeek;
int weeksPerYear;
int milesPerGallon;
double pricePerGallon;

cout << "How many miles round-trip a day do you commute?";
cin >> milesPerDay;
cout << "How many days a week do you commute?";
cin >> daysPerWeek;
cout << "How many weeks a year do you commute?";
cin >> weeksPerYear;
cout << "How many miles per gallon does your vehicle get?";
cin >> milesPerGallon;
cout << "What is the current per gallon price of gas?";
cin  >> pricePerGallon;

int milesPerYear = milesPerDay * daysPerWeek * weeksPerYear;
int gallonsPerYear = milesPerYear / milesPerGallon;
double gasMoneyPerYear = gallonsPerYear * pricePerGallon;
double monthlyGasExpense = gasMoneyPerYear / 12;
cout << milesPerDay << " " << "miles a day" << endl;
cout << daysPerWeek << " " << "days a week" << endl;
cout << weeksPerYear << " " << "weeks a year" << endl;
cout << milesPerGallon << " " << "miles per gallon" << endl;
cout << "\$" << pricePerGallon << " " << "per gallon" << endl;
cout << "monthly gas expense:" << "  " << monthlyGasExpense << endl;
system("pause");

char loop = 'Y' || 'y';
cout << "Would you like to do another cost of commute calculation?"
<< "Enter y for yes enter n for no" << endl;
cin >> loop;
if (loop = 'Y' || 'y') {

}```
What do I do in order to get the program to loop?

2. Code:
```#include <iostream>
using namespace std;

int main(int, char**) {
int milesPerDay;
int daysPerWeek;
int weeksPerYear;
int milesPerGallon;
double pricePerGallon;
char loop = 'Y' ;

do{

cout << "How many miles round-trip a day do you commute?";
cin >> milesPerDay;
cout << "How many days a week do you commute?";
cin >> daysPerWeek;
cout << "How many weeks a year do you commute?";
cin >> weeksPerYear;
cout << "How many miles per gallon does your vehicle get?";
cin >> milesPerGallon;
cout << "What is the current per gallon price of gas?";
cin  >> pricePerGallon;

int milesPerYear = milesPerDay * daysPerWeek * weeksPerYear;
int gallonsPerYear = milesPerYear / milesPerGallon;
double gasMoneyPerYear = gallonsPerYear * pricePerGallon;
double monthlyGasExpense = gasMoneyPerYear / 12;
cout << milesPerDay << " " << "miles a day" << endl;
cout << daysPerWeek << " " << "days a week" << endl;
cout << weeksPerYear << " " << "weeks a year" << endl;
cout << milesPerGallon << " " << "miles per gallon" << endl;
cout << "\$" << pricePerGallon << " " << "per gallon" << endl;
cout << "monthly gas expense:" << "  " << monthlyGasExpense << endl;
system("pause");

cout << "Would you like to do another cost of commute calculation?"
<< "Enter y for yes enter n for no" << endl;
cin >> loop;
}while (loop=='Y' || loop=='y');

}```

3. ## lol

Thanks, I thought it might be that but it seemed wrong wasn't thinking ><