title: Java Parking fee calculations
body: <p>It seems like, I couldn't find the answer for my problem, so here I am, first on Stackoverflow :) </p>
  
  <p>The If statement tree that will be mentioned:</p>
  
  <pre><code>buttonSzamol.addActionListener(new ActionListener() {
  
          @Override
          public void actionPerformed(ActionEvent e) {
  
              //Változók
  
                  int StartHour = 18;
                  int StartMin = 50;
                  int StopHour = 20;
                  int StopMin = 49;
                  int DayTimeIntervalStart = 6;
                  int DayTimeIntervalStop = 17;
                  int NightTimeIntervalLateStart = 18;
                  int NightTimeIntervalLateStop = 23;
                  int NightTimeIntervalEarlyStart = 0;
                  int NightTimeIntervalEarlyStop = 5;
                int DayHoursTotal = 0;
                  int NightHoursTotal = 0;
                  int DayTimePricePerHour = Integer.parseInt(NappaliOraDij.getText());
                  int NightTimePricePerHour = Integer.parseInt(EjszakaiOraDij.getText());
  
                  int StartDay = Integer.parseInt((DatumStart.getText()).replace(".", ""));
                  int StopDay = Integer.parseInt((DatumStart.getText()).replace(".", ""));
  
                  //1 started hour
                  if( (StartDay == StopDay) &amp;&amp; ( ( (StartHour == StopHour) &amp;&amp; (StartMin &lt; StopMin) ) || ( ((StartHour + 1) == StopHour) &amp;&amp; (StartMin &gt;= StopMin) ) ) ) {
                      if((DayTimeIntervalStart &lt;= StartHour) &amp;&amp; (StopHour &lt;= DayTimeIntervalStop)) {
                          DayHoursTotal++;
                      }
                      if((NightTimeIntervalLateStart &lt;= StartHour) &amp;&amp; (StopHour &lt;= NightTimeIntervalLateStop)) {
                          NightHoursTotal++;
                      }
                  } else/*More hours*/if( (StartDay == StopDay) &amp;&amp; ( ( (StartHour &lt; StopHour) &amp;&amp; (StartMin &lt;= StopMin) ) || ( (StartHour &lt; StopHour) &amp;&amp; (StartMin &gt; StopMin) ) ) ) {
                      if( (StartHour &lt; StopHour) &amp;&amp; (StartMin &lt; StopMin) ) {
                          if((DayTimeIntervalStart &lt;= StartHour) &amp;&amp; (StopHour &lt;= DayTimeIntervalStop)) {
                              DayHoursTotal = DayHoursTotal + (StopHour - StartHour);
                              DayHoursTotal++;
                          }
                          if((NightTimeIntervalLateStart &lt;= StartHour) &amp;&amp; (StopHour &lt;= NightTimeIntervalLateStop)) {
                              NightHoursTotal = NightHoursTotal + (StopHour - StartHour);
                              NightHoursTotal++;
                          }
                      }else if(( (StartHour &lt; StopHour) &amp;&amp; (StartMin &gt;= StopMin) )) {
                          if((DayTimeIntervalStart &lt;= StartHour) &amp;&amp; (StopHour &lt;= DayTimeIntervalStop)) {
                              DayHoursTotal = DayHoursTotal + (StopHour - StartHour);
                              if(StartMin != StopMin) {
                                  DayHoursTotal--;
                              }
                          }
                          if((NightTimeIntervalLateStart &lt;= StartHour) &amp;&amp; (StopHour &lt;= NightTimeIntervalLateStop)) {
                              NightHoursTotal = NightHoursTotal + (StopHour - StartHour);
                              if(StartMin != StopMin) {
                                  NightHoursTotal--;
                              }
                          }
                      }
                  }
  
              NappaliOrak.setText(Integer.toString(DayHoursTotal));
              EjszakaiOrak.setText(Integer.toString(NightHoursTotal));
              OrakOsszesen.setText(Integer.toString(DayHoursTotal + NightHoursTotal));
              NappaliOsszeg.setText(Integer.toString(DayHoursTotal * DayTimePricePerHour));
              EjszakaiOsszeg.setText(Integer.toString(NightHoursTotal * NightTimePricePerHour));
              VegOsszeg.setText(Integer.toString((DayHoursTotal * DayTimePricePerHour) + (NightHoursTotal * NightTimePricePerHour)));
          }
      });
  </code></pre>
  
  <p>So, the problem in a nutshell is. 
  I've tried to create a parking fee calculator for my colleague at work.
  The main idea is, that it needs to calculate how many Daytime and how many Nighttime hours the client started, and it needs to calculate the price of those hours. I've changed the StartHour/Min-StopHour/Min fields to straight integers to be more understanable. I don't know if there is a module for this, but I started doing this with a lot of If statements, where I just got tangled up. In the included pastebin, there is starting time 18:50 and stop time 20:49. If we input this data, the output should be 2 started day hours. Now if the minute is the same, it does not count as a started hour. But if we change the input to 20:51, then it started an another hour, so the DayHoursTotal should be equal to 3. </p>
  
  <p>Thank you in advance, for any help. If you have more questions about my code or idea, just ask. </p>