need it quick!!!

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>

using namespace std;

int main() {

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;

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();
}
Last edited on
change the data types to double
1
2
3
4
double miles;
double capacity;
double cookies;
double angle;


BTW, we have different timezones LOL
looollzzz I knww :-PP


ok so I changed them but I am still having 4 errors, could u plzz try it and tell me what is happening :-|||

thanxx
this is the updated program i didnt do many corrections beside i had only one error!
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//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>

using namespace 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();
}
Topic archived. No new replies allowed.