logic problem with best out of 3 jumps

i want the user to enter 3 dates and 3 pole jumps and give the jumps and dates in the order of best to least but i"m having errors and logic mistakes can some one help me, i // the first part to focus on the beginning then i was going t get the rest.

#include<iostream>
#include<iomanip>
using namespace std;
int main ()

{

double date1,date2,date3,hight1,hight2,hight3;
const int name = 11;
char word[name];

cout <<"please enter your first name:"<<endl;
cin >>setw(name) >> word;

cout <<"please enter the dates you jumped example (2008)"<<endl;
cout <<"date one: "<<endl;
cin >>date1;
cout <<"date two: "<<endl;
cin >>date2;
cout <<"date three: "<<endl;
cin >>date3;
cout <<"now the hight example (2.0)"<<endl;

cout <<"hight one: "<<endl;
cin >>hight1;
cout <<"hight two: "<<endl;
cin >>hight2;
cout <<"hight three: "<<endl;
cin >>hight3;


if (hight1 < 2.0)
{
cout <<"error no jummp's under 2.0"<<endl;
return 0;
}



if (hight2 < 2.0)
{
cout <<"error no jummp's under 2.0"<<endl;
return 0;
}



if (hight3 < 2.0)
{
cout <<"error no jummp's under 2.0"<<endl;
return 0;
}



if (hight1 > 5.0)
{
cout <<"this hight is not humanly possible"<<endl;
return 0;
}



if (hight2 > 5.0)
{
cout <<"this hight is not humanly possible"<<endl;
return 0;
}


if (hight3 > 5.0)
{
cout <<"this hight is not humanly possible"<<endl;
return 0;
}


////////////////////////////////////////////////////////////////////////////


if (hight1 > hight2 && hight1 > hight3)
{


{

cout <<"your best jump was " <<date1 <<" "<<hight1<<endl;


if(hight1 > hight2 && hight1 > hight3)
{
cout <<"your second jump was "<<date2 <<" "<<hight2<<endl;
cout <<"your third jump was " <<date3 <<" "<<hight3<<endl;
}


else if (hight1 > hight2 && hight1 > hight3)
{
cout <<"your second jump was "<<date3 <<" "<<hight3<<endl;
cout <<"your third jump was " <<date2 <<" "<<hight2<<endl;
}

}





// else if (hight2 > hight1 && hight2 > hight3)

// {

// cout <<"your best jump was " <<date2 <<" "<<hight2<<endl;
// cout <<"your second jump was "<<date1 <<" "<<hight1<<endl;
/// cout <<"your third jump was " <<date3 <<" "<<hight3<<endl;

// }


// else if(hight3 > hight2 && hight3 > hight1)

// {

// cout <<"your best jump was " <<date3 <<" "<<hight3<<endl;
// cout <<"your second jump was "<<date2 <<" "<<hight2<<endl;
// cout <<"your third jump was " <<date1 <<" "<<hight1<<endl;

// }

// else if(hight3 > hight1 && hight3 > hight2)

// {
// cout <<"your best jump was " <<date3 <<" "<<hight3<<endl;
// cout <<"your second jump was "<<date1 <<" "<<hight1<<endl;
// cout <<"your third jump was " <<date2 <<" "<<hight2<<endl;

// }
//

////////////////////////////////////////////////////////////////////////////

if (hight1 == hight2)
{
cout <<"jump 1 and jump 2 are the same" <<endl;
cout <<"jump 3 is least"<<endl;
}

if (hight3 == hight1)
{
cout <<"jump 3 and jump 1 are the same" <<endl;
cout <<"jump 2 is least"<<endl;
}

if (hight2 == hight3)
{
cout <<"jump 3 and jump 2 are the same" <<endl;
cout <<"jump 1 is least"<<endl;
}

}

return 0;

}
After if (hight1 > hight2 && hight1 > hight3) You open one uneccecary bracket '{' and you include the rest of your code in this if...
You should close the if after cout <<"your best jump was " <<date1 <<" "<<hight1<<endl;

Here is the code so you can see it:
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>
#include<iomanip>
using namespace std;
int main ()
{
   double date1,date2,date3,hight1,hight2,hight3;
   const int name = 11;
   char word[name];
   cout <<"please enter your first name:"<<endl;
   cin >>setw(name) >> word;
   cout <<"please enter the dates you jumped example (2008)"<<endl;
   cout <<"date one: "<<endl;
   cin >>date1;
   cout <<"date two: "<<endl;
   cin >>date2;
   cout <<"date three: "<<endl;
   cin >>date3;
   cout <<"now the hight example (2.0)"<<endl;
   cout <<"hight one: "<<endl;
   cin >>hight1;
   cout <<"hight two: "<<endl;
   cin >>hight2;
   cout <<"hight three: "<<endl;
   cin >>hight3;
   if (hight1 < 2.0)
   { 
      cout <<"error no jummp's under 2.0"<<endl;
      return 0;
   }
   if (hight2 < 2.0)
   { 
      cout <<"error no jummp's under 2.0"<<endl;
      return 0;
   }
   if (hight3 < 2.0)
   { 
      cout <<"error no jummp's under 2.0"<<endl;
      return 0;
   }
   if (hight1 > 5.0)
   {
      cout <<"this hight is not humanly possible"<<endl;
      return 0;
   }
   if (hight2 > 5.0)
   {
      cout <<"this hight is not humanly possible"<<endl;
      return 0; 
   }
   if (hight3 > 5.0)
   {
      cout <<"this hight is not humanly possible"<<endl;
      return 0;
   }

   if (hight1 > hight2 && hight1 > hight3)
   { 
      cout <<"your best jump was " <<date1 <<" "<<hight1<<endl;
   }//You forghot to close the bracket here
   else if(hight1 > hight2 && hight1 > hight3) 
   {
      cout <<"your second jump was "<<date2 <<" "<<hight2<<endl;
      cout <<"your third jump was " <<date3 <<" "<<hight3<<endl;
   }
   else if (hight1 > hight2 && hight1 > hight3) 
   {
      cout <<"your second jump was "<<date3 <<" "<<hight3<<endl;
      cout <<"your third jump was " <<date2 <<" "<<hight2<<endl;
   }
   if (hight1 == hight2)
   {
      cout <<"jump 1 and jump 2 are the same" <<endl;
      cout <<"jump 3 is least"<<endl;
   }
   if (hight3 == hight1)
   {
      cout <<"jump 3 and jump 1 are the same" <<endl;
      cout <<"jump 2 is least"<<endl;
   }
   if (hight2 == hight3)
   {
      cout <<"jump 3 and jump 2 are the same" <<endl;
      cout <<"jump 1 is least"<<endl;
   }
   return 0;
}


Hope this helps

PS please use the code tags at the right of the post or the [code][/code] to include your code in...
Topic archived. No new replies allowed.