unable to correct this program

I trying to make this program .I tried several techniques to fix it but nothing worked for me .Can anyone please tell me what is the problem with this program.


#include<iostream>
using namespace std;
double MilesperGal(double F,double m)
{
double M;



M = m/F;
return M;


}
double mileage(double F,double M)
{
double m;

m=F*M;


return m;

}
double fuelUsed (double M,double MPG)
{
double f;


f=M/MPG;


return f;


}
int main()
{
double FuelUsed;
double Mileage;
double MilesPerGal;

char x ;

cout<<"Enter M to caluculate mileage , D for distance traveled ,G for Gal per miles and Q to quit the program ";
cin>>x ;

cout << x << endl ;

switch (x)
{
case 'm':
case 'M':

cout << "enter the fuel used";
cin>>FuelUsed;
cout<<"enter mileage ";
cin>>Mileage;
cout <<double MilesperGal(double F,double m);

break ;
case 'd':
case 'D':
cout << "enter the fuel used";
cin>>FuelUsed;
cout<<"enter MPG ";
cin>>MilesPerGal;


cout <<double mileage(double F,double M);

break ;
case 'g':
case 'G':
cout << "enter the Mileage used";
cin>>Mileage;
cout<<"enter mileage ";
cin>>MilesPerGal;
cout << double fuelUsed (double M,double MPG) ;



default:
return 0; }

}
This looks the same as the thread which jsmith is helping you with.
Why are you duplicating and why don`t you put your code within code tags?? by selecting the code and hitting # under format (RHS of code window)This really helps others to read you code.
Last edited on
Just a small note: I don't even read code that isn't in the code tags. It's hard on the eyes and, well, that's all it takes for me to move on.
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
#include<iostream>
using namespace std;
double MilesperGal(double F,double m)
{
double M;



M = m/F;
return M;


}
double mileage(double F,double M)
{
double m;

m=F*M;


return m;

}
double fuelUsed (double M,double MPG)
{
double f;


f=M/MPG;


return f;


}
int main()
{
double FuelUsed;
double Mileage;
double MilesPerGal;

char x ;

cout<<"Enter M to caluculate mileage , D for distance traveled ,G for Gal per miles and Q to quit the program ";
cin>>x ;

cout << x << endl ;

switch (x)
{
case 'm':
case 'M':

cout << "enter the fuel used";
cin>>FuelUsed;
cout<<"enter mileage ";
cin>>Mileage;
cout <<double MilesperGal(double F,double m);
 //otherwise you declare the function not call it. This problem occurs 2 more times

break ;
case 'd':
case 'D':
cout << "enter the fuel used";
cin>>FuelUsed;
cout<<"enter MPG ";
cin>>MilesPerGal;


cout <<double mileage(double F,double M);

break ;
case 'g':
case 'G':
cout << "enter the Mileage used";
cin>>Mileage;
cout<<"enter mileage ";
cin>>MilesPerGal;
cout << double fuelUsed (double M,double MPG) ;



default:
return 0; }

}
Topic archived. No new replies allowed.