Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   help confuse bout this java (http://www.go4expert.com/forums/help-confuse-bout-java-t19718/)

 eyeore 9Oct2009 15:22

help confuse bout this java

help please im really confuse about this problem its about computation about a telephone bill but my first variable keep messing up with my second variable which is my first variable is 2.50 dollars and my second is 2.00 dollars
but when i tried my code started day 1 hours 00 min 30 end hours 1 min 30 its duration its 60 by bill is 150
when i tried to do it again day 1started hours 06 min 30 end hours 07 min 30
the same thing happen duration 60 and bill 150 the first hour 00 min 30 and end hour 1 min 30 should have suppose to be " duration 60 and bill 120 " please can anyone kindly me help me whats wrong with my variable i really dont know what do anymore

Code:

```import java.util.Scanner; public class act8 {         public static void main(String[] args) {         Scanner input = new Scanner(System.in);                         int num;             int startHrs;             int endHrs;             int duration;             int startMin;             int endMin;             int bill;                                     System.out.println("Enter Day");             num = input.nextInt();                         if(num >= 5){                 System.out.print("Call started hours");                 startHrs = input.nextInt();                 System.out.print("Minutes");                 startMin = input.nextInt();                 System.out.print("Call ended hours");                 endHrs = input.nextInt();                 System.out.print("Minutes");                 endMin = input.nextInt();                 if (startHrs >= 6 && endHrs >= 18){                     startHrs = endHrs - startHrs;                     duration = startHrs * 60 - startMin + endMin;                     System.out.print("Duration "+ duration);                     bill = (int) (duration * 2.50);                     System.out.println("Bill"+ bill);                     System.exit(0);                                     if(num >=5)                     if(startHrs <=24)                     startHrs = endHrs - startHrs;                     duration = startHrs * 60 - startMin + endMin;                     System.out.print("Duration "+ duration);                     bill = (int) (duration * 2.00);                     System.out.println("Bill"+ bill);                     System.exit(0);                                     if(num <= 7){                             System.out.print("Call started hours");                             startHrs = input.nextInt();                             System.out.print("Minutes");                             startMin = input.nextInt();                             System.out.print("Call ended hours");                             endHrs = input.nextInt();                             System.out.print("Minutes");                             endMin = input.nextInt();                             if (startHrs < 24){                                 startHrs = endHrs - startHrs;                                 duration = startHrs * 60 - startMin + endMin;                                 System.out.print("Duration "+ duration);                                 bill = (int) (duration * 1.50);                                 System.out.println("Bill"+ bill);                                 System.exit(0);                             }                     }                 }             }     }     }```

 All times are GMT +5.5. The time now is 07:16.