Another n00b variable question...
              in 
             Programming Questions 
              •  
              1 years ago    
            
 
           
             To start off I understand the concept of private and public variables (at least I think that I do).
            
             
             
              
             
             
              
             
             
              
             
              
           
 
            
           
              My question is:
             
             
              When you change the value of a variable in a class (in my example an "if statement"), once I close the class (or if statement) with an } is there anyway to allow the rest of my program to see the new value of the variable?
             
             
              What I would like to do is use the result of my if statement in further calculations. I realize I could put the rest of my calculations right into the if statement; however this requires twice as much code. 
             
             
              Example below:
             
             
              double st = 10
              
              
               
             
            
                double ha;
               
               
                      if ((st/4) < 0){
               
               
                        double ha = st/4+180; // =182.5
               
               
                        println ("Hour Angle (Deg): " + ha); // prints 182.5
               
               
                      }else{
               
               
                        double ha = st/4-180; // =-177.5
               
               
                        println ("Hour Angle (Deg): " + ha); //prints -177.5
               
               
                      } 
               
               
                      println ("Hour Angle (Deg): " + ha); //prints 0    (How can I get this to print the value given to the variable within the IF statement?)
               
               
              
              1  
            
 
            
 
 
           
 
            