SOME ASSISTANT please ^_^ I need help with a Dual if statement

Hey guys this is my first post, I've tried figuring this out myself, but I'am really stuck.

I'm new to programing so this may be an easy solution.

I am trying to have an if statement will determine weather an integer is higher then two other ints, not just one for example.

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

        
    if ( total_uom > total_wcc )
     {  
      if ( total_uom > total_emu) 
       
       cout << " The University of Michigan is $" << total_uom - total_emu <<" dollars more then Eastern Michigan \n"
               " and $" << total_uom - total_wcc << " dollars more then expense then Washtenaw Commnity College" <<endl<<endl;
      }
      
      
      
     if ( total_wcc > total_uom) 
      { 
       if ( total_wcc > total_emu)
       
       cout << " Washtenaw Community College is $" << total_wcc - total_emu << "dollars more expense then Eastern Michigan\n"
            << " and $" << total_wcc - total_uom <<" dollars more expense then The Universtiy of Michigan."<<endl<<endl;
       } 
    
    
       if ( total_emu > total_wcc)
      
      {
            if ( total_emu > total_emu)
              
              cout << " Eastern Michigan is $" << total_emu - total_wcc << " dollars more then Washtenaw Community College \n"
                   << " and $" << total_emu - total_uom << " dollars more expense then The University of Michigan."<<endl<<endl;
      }
      
  
  cout <<endl;
  
  cout << "Thanks for using this program " <<firstname<< " it was keyed in by Sidney S." <<endl;
  
  cout <<endl;
  
  cout << " Press 'c' to  end the program";  
         cin >> z;
         
         return 0;
         
         }


I want a statement that will be able to solve:

if ( a > b AND c)
then cout << "so forth"

if (b > a AND c)
then cout << "so forth"

etc

Thanks guys I really appreciate the help
e.g.

1
2
3
4
if ( ( total_uom > total_wcc ) && ( total_uom > total_emu ) )
{  
    ...
}

So Shacktar what I entered was:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 if ((total_uom > total_wcc ) && ( total_uom > total_emu)){ 
    
    cout << " The University of Michigan is $" << total_uom - total_emu <<" dollars more then Eastern Michigan \n"
               " and $" << total_uom - total_wcc << " dollars more then expense then Washtenaw Commnity College" <<endl<<endl;}
      
      
      
      
     if (( total_wcc > total_uom) && ( total_wcc > total_emu)) {
       
       cout << " Washtenaw Community College is $" << total_wcc - total_emu << "dollars more expense then Eastern Michigan\n"
            << " and $" << total_wcc - total_uom <<" dollars more expense then The Universtiy of Michigan."<<endl<<endl;}
     
    
    
       if (( total_emu > total_wcc) && ( total_emu > total_emu)){
              
              cout << " Eastern Michigan is $" << total_emu - total_wcc << " dollars more then Washtenaw Community College \n"
                   << " and $" << total_emu - total_uom << " dollars more expense then The University of Michigan."<<endl<<endl;}
      


What happens is, if "total_uom" is the highest it will display that function, but if its not, it just goes to the end of the program, I can't get it to acknowledge the other options happening.

any tips?
else if
I can't see anything wrong with those three statements (besides the placement of the curly brackets).

Post the whole code (likely the problem is somewhere else)
Maybe I'm doing it wrong lol, I just tried :
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
 
if ((total_uom > total_wcc ) && ( total_uom > total_emu)){ 
  
    cout << " The University of Michigan is $" << total_uom - total_emu <<" dollars more then Eastern Michigan \n"
               " and $" << total_uom - total_wcc << " dollars more then expense then Washtenaw Commnity College" <<endl<<endl;}
      
      
      
      
     else if (( total_wcc > total_uom) && ( total_wcc > total_emu)) {
       
       cout << " Washtenaw Community College is $" << total_wcc - total_emu << "dollars more expense then Eastern Michigan\n"
            << " and $" << total_wcc - total_uom <<" dollars more expense then The Universtiy of Michigan."<<endl<<endl;}
     
    
    
       else if  (( total_emu > total_wcc) && ( total_emu > total_emu)){
              
              cout << " Eastern Michigan is $" << total_emu - total_wcc << " dollars more then Washtenaw Community College \n"
                   << " and $" << total_emu - total_uom << " dollars more expense then The University of Michigan."<<endl<<endl;}
      
      
  
  cout <<endl;
  
  cout << "Thanks for using this program " <<firstname<< " it was keyed in by Sidney S." <<endl;
  
  cout <<endl;
  
  cout << " Press 'c' to  end the program";  
         cin >> z;
         
         return 0;
         
         }
                        


it still doesn't go to the other options if they are correct, it only doe the first one, and if the first one isn't true it goes to the ending
Last edited on
Probably you have an uninitialized variable or something before this code. Let's see the code before as well.
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#include <iostream>

using namespace std;

//******* Washtenaw Credit Fees****************
const double COST_OF_WCC_COURSE    = 87.00;
//*********Ending of Washtenaw const***********

//**********Easterns Credit Fees***************
const double COST_OF_EMU_COURSE    = 238.77;
 
const double GENERAL_FEE           = 23.50;

const double TECH_FEE              = 11.15;

const double STUDENT_UNION         = 3.35;

const double BUSINESS_FEE          = 54.00;
//**********Ending of EMU Credit Fees**********

//***********Michigans Credit Fees*************
const double COST_OF_UOM_CREDIT1   = 812.00;

const double COST_OF_UOM_CREDIT2   = 456.00; 

const double REGISTRATION_FEE      = 80.00;

const double STUDENT_ASSEMBLY_FEE  = 7.19;

const double STUDENT_LEGAL_SRV     = 6.00;

const double STUDENT_GOV_FEE       = 1.50;
//******Ending of Michigans Credit Fee********



int main()

{

          string firstname;

          

          char  z;     
           /* This is used to help the user to continue the program, I 

             use it as a way to pause. ( I used char function, to help alleviate 
             
               the use of too many keys being used*/
               
          double credits, wcc_cost, emu_cost, uom_cost, mileswcc, milesemu, milesuom, cummute_costwcc,cummute_costemu,cummute_costuom, mile_cost ;     
          double total_uom,total_emu,total_wcc;



    cout << "          Welcome to Tuition Calculator!"<<endl;
  
    cout <<endl;
    
    cout << "          Please enter your name below :"<<endl;
         
    cin >> firstname;
        
    cout <<endl <<endl;
        
    cout << "     This Program will calculate the tuition cost difference between\n\n"
         << "                 Washtenaw Community College\n\n"
         << "                 Eastern Michigan University\n\n"
         << "                             &              \n\n"
         << "                  The University of Michigan\n\n";
             
    cout <<endl; 
     
    cout << " Thank You " << firstname << " We will begin now"<<endl;
    
    cout <<endl;
    
    cout << "Press 'c' to continue"<<endl;
         cin >> z   ;
         
    cout <<endl;
   
    cout <<endl;
    
    cout << "                Enter the amount of credits you plan to take: ";
        
    cin >> credits;
    
    cout <<endl <<endl; 
    
    cout << " Please enter your cost per mile ( example: 0.25 for 25 cents):"<<endl;
       
    cin >> mile_cost;
        
    cout << endl << endl;
    
    
    cout << " Enter your distance to WCC\n (miles in whole digits eg. 1,2,3) :" ;
         
    cin >> mileswcc;
    
    cout <<endl;
    
    cout << " Enter your distance to EMU\n (miles in whole digits eg. 1,2,3) (miles) :" ;
         cin >> milesemu;
   
    cout<<endl;
    
    cout<< " Enter our distance to UoM\n (miles in whole digits eg. 1,2,3) (miles) :"  ;
          cin >> milesuom;
    
    cout <<endl <<endl;
    
    cout << " Press 'c' to contine";
         cin >> z;
         
    
    // The formula below will calcuate cummute_cost
    
    cummute_costwcc = (mileswcc * 2) * mile_cost;  // Because this a round trip I mulitplied the miles by 2
    
    cummute_costemu = (milesemu * 2)* mile_cost;
    
    cummute_costuom = (milesuom * 2) * mile_cost;
    
    // Now I wll calculate the credits for each school
     wcc_cost = credits * COST_OF_WCC_COURSE;
     
     emu_cost = (credits * COST_OF_EMU_COURSE) + GENERAL_FEE + TECH_FEE + STUDENT_UNION +  
                                                 BUSINESS_FEE;
     uom_cost = ((credits - 1) * COST_OF_UOM_CREDIT2) + COST_OF_UOM_CREDIT1 + // I subtracted 1 from the orignal credit amount so that I could properly get the credit cost
                               REGISTRATION_FEE + STUDENT_ASSEMBLY_FEE +
              STUDENT_LEGAL_SRV +  STUDENT_GOV_FEE;
    // Calculate Credit Cost has been estiblished under the int wcc_cost,emu_cost,uom_cost.
    
    
    cout << " The tuition and fees for WCC total: $" << wcc_cost<<endl;
   
    cout << " Your driving cost is : $" << cummute_costwcc<<endl;
   
    cout << " Your Total Cost is : $" <<cummute_costwcc + wcc_cost <<endl;
    
    
    total_wcc = cummute_costwcc + wcc_cost; // a double that I will use at the near the ending
    
    cout <<endl <<endl;
    
    cout << " Press 'c' to continue to EMU Costs"<<endl;
        
    cin >> z;
         
    cout << endl <<endl;
     
    cout <<" The tuition and fees for EMU total: $" << emu_cost<<endl;
    
    cout <<" Your driving cost is : $" << cummute_costemu <<endl;
    
    cout <<" Your Total Cost is : $" <<cummute_costemu + emu_cost <<endl; 
    
    total_emu = cummute_costemu + emu_cost;
    
    cout << " Press 'c' to contine to UoM Costs"<<endl;
         
    cin >> z;
         
    cout <<endl <<endl;
    
    cout <<" The tuition and fees for UOM total: $" << uom_cost<<endl;
    
    cout <<" Your driving cost is : $" << cummute_costuom <<endl;
   
    cout <<" Your Total Cost is : $" <<cummute_costuom + uom_cost ; 
    
    total_uom = cummute_costuom + uom_cost;
    
    cout <<endl <<endl <<endl;
   
   
   cout << " Press 'c' to compare the cost differences"<<endl;
       
   cin >> z;
        
        
    // The following function will take the higher of the cost, and tell you how much more expensive it is to its counterparts.
   
   
   
        
    if ((total_uom > total_wcc ) && ( total_uom > total_emu)){ 
    
    cout << " The University of Michigan is $" << total_uom - total_emu <<" dollars more then Eastern Michigan \n"
               " and $" << total_uom - total_wcc << " dollars more then expense then Washtenaw Commnity College" <<endl<<endl;}
      
      
      
      
     else if (( total_wcc > total_uom) && ( total_wcc > total_emu)) {
       
       cout << " Washtenaw Community College is $" << total_wcc - total_emu << "dollars more expense then Eastern Michigan\n"
            << " and $" << total_wcc - total_uom <<" dollars more expense then The Universtiy of Michigan."<<endl<<endl;}
     
    
    
       else if  (( total_emu > total_wcc) && ( total_emu > total_emu)){
              
              cout << " Eastern Michigan is $" << total_emu - total_wcc << " dollars more then Washtenaw Community College \n"
                   << " and $" << total_emu - total_uom << " dollars more expense then The University of Michigan."<<endl<<endl;}
      
      
  
  cout <<endl;
  
  cout << "Thanks for using this program " <<firstname<< " it was keyed in by Sidney S." <<endl;
  
  cout <<endl;
  
  cout << " Press 'c' to  end the program";  
         cin >> z;
         
         return 0;
         
         }
                              


There is the WHOLE sha bang lol, Im not sure what Im doing wrong
Oops, copy-and-paste bug at 12 O'clock (need to go to bed soon)

else if (( total_emu > total_wcc) && ( total_emu > total_emu))
DUDE!!!! SHACKTAR!!!!!!! .....all I can say is.....I love you


...that simple issue has been solved (now I can go back and fix 3 other programs lol)


Thanks so Much dude ^_^!!!!!
As a side note, you can do this in one combined statement. I know it is very messy, but just another method:
1
2
3
int a,b,c;
//Initialise the values...
cout << (((a>b)?a:b)>c)?(((a>b)?a:b):c)


This can e simplified by making a function:
1
2
3
4
5
6
7
int GetMax (int a, int b)
{
        return a>b?
}

//.....
   GetMax(  Max(a,b),  c  )
Topic archived. No new replies allowed.