int miles;
int capacity;
int cookies;
int angle;
int choice;
ofstream file;
file.open("hanan-natouf.dat");
do {
cout
<< "Choose one of the following calculations, or choose to quit this program."
<< endl << endl;
file
<< "Choose one of the following calculations, or choose to quit this program."
<< endl << endl;
cout << "1. Miles per gallon" << endl;
file << "1. Miles per gallon" << endl;
cout << "2. Calories in cookies" << endl;
file << "2. Calories in cookies" << endl;
cout << "3. Angle Calculator" << endl;
file << "3. Angle Calculator" << endl;
cout << "4. Quit" << endl;
file << "4. Quit" << endl;
cout << endl
<< "Enter the number of the calculation that you would like executed (or enter 4 to quit) ? ";
file << endl
<< "Enter the number of the calculation that you would like executed (or enter 4 to quit) ? ";
cin >> choice;
while (choice < 1 || choice > 4) {
cout << "Please enter 1, 2, 3, or 4: ";
file << "Please enter 1, 2, 3, or 4: ";
cin >> choice;
}
switch (choice) {
case 1:
cout << endl << "Enter the number of gallons : ";
file << endl << "Enter the number of gallons : ";
cin >> capacity;
cout << "Enter the number of miles : ";
file << "Enter the number of miles : ";
cin >> miles;
cout << "Car can be driven " << miles / capacity
<< " miles per gallon." << endl;
file << "Car can be driven " << miles / capacity
<< " miles per gallon." << endl;
break;
case 2:
cout << endl << "Enter the number of cookies you ate : ";
file << endl << "Enter the number of cookies you ate : ";
cin >> cookies;
//could you plzz tell me what is wrong with my program ????? now before it becomes 11:oo thanxxx
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
usingnamespace std;
int main() {
double miles;
double capacity;
double cookies;
double angle;
int choice;
ofstream file;
file.open("hanan-natouf.dat");
do {
cout<< "Choose one of the following calculations, or choose to quit this program."<< endl << endl;
file<< "Choose one of the following calculations, or choose to quit this program."<< endl << endl;
cout << "1. Miles per gallon" << endl;
file << "1. Miles per gallon" << endl;
cout << "2. Calories in cookies" << endl;
file << "2. Calories in cookies" << endl;
cout << "3. Angle Calculator" << endl;
file << "3. Angle Calculator" << endl;
cout << "4. Quit" << endl;
file << "4. Quit" << endl;
cout << endl
<< "Enter the number of the calculation that you would like executed (or enter 4 to quit) ? ";
file << endl
<< "Enter the number of the calculation that you would like executed (or enter 4 to quit) ? ";
cin >> choice;
while (choice < 1 || choice > 4) {
cout << "Please enter 1, 2, 3, or 4: ";
file << "Please enter 1, 2, 3, or 4: ";
cin >> choice;
}
switch (choice) {
case 1:
cout << endl << "Enter the number of gallons : ";
file << endl << "Enter the number of gallons : ";
cin >> capacity;
cout << "Enter the number of miles : ";
file << "Enter the number of miles : ";
cin >> miles;
cout << "Car can be driven " << miles / capacity
<< " miles per gallon." << endl;
file << "Car can be driven " << miles / capacity
<< " miles per gallon." << endl;
break;
case 2:
cout << endl << "Enter the number of cookies you ate : ";
file << endl << "Enter the number of cookies you ate : ";
cin >> cookies;
cout << "You consumed " << cookies * (300 / (40 / 10))
<< " calories." << endl;
file << "You consumed " << cookies * (300 / (40 / 10))
<< " calories." << endl;
break;
case 3:
cout << endl << "Enter the angle : ";
file << endl << "Enter the angle : ";
cin >> angle;
cout << "Sine of angle" << angle << " is " << fixed<< setprecision(4) << sin(angle) << endl;
file << "Sine of angle" << angle << " is " << fixed<< setprecision(4) << sin(angle) << endl;
cout << "Cosine of angle" << angle << " is " << fixed<< setprecision(4) << sin(angle) << endl;
file << "Cosine of angle" << angle << " is " << fixed<< setprecision(4) << cos(angle) << endl;
cout << "Tangent of angle" << angle << " is " << fixed<< setprecision(4) << tan(angle) << endl;
file << "Tangent of angle" << angle << " is " << fixed<< setprecision(4) << tan(angle) << endl;
break;
}
} while (choice != 4);
file.close();
}