problem based task oop

1,527 views
1,315 views

Published on

problem based task object oriented pragramming 2012 | PSMZA |

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,527
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

problem based task oop

  1. 1.  We are assigned with a Problem Based Task in topic system payment for a parking meter. We have to create a system that accept an input from user and give out the output for them.
  2. 2.  One of our objective is to make an easier way for a user to use a parking system. We provide the great way for parking payment and give special offer for member and our loyal customer.
  3. 3.  The system that we have build is consist of the use of control statements. As example, we used looping statement which is used to make our system loop again and again without fail. Despite that, we also use selection statement (if-else) to provide the user with a better choice.
  4. 4.  By just key in the time you’ve enter and exit, our program will calculate it for you. No more wasting time like when we using in manual way. After the amount of payment appear on the screen, you can make the payment directly.
  5. 5.  import java.io.*; public class Park { public static void main(String args[]) throws Exception { BufferedReader axm = new BufferedReader(new InputStreamReader(System.in)) ; int x; int y; int b;
  6. 6.  for(int i=0;i<50;i++) { System.out.println("This parking system is based on 24 hours "); System.out.println("Please key in your choices in format 24 hours"); System.out.println("Check in :"); x = Integer.parseInt(axm.readLine()); System.out.println("Check out :"); y = Integer.parseInt(axm.readLine()); } }
  7. 7.  System.out.println("1) Non-Member 2) Membern"); System.out.println("Your choice:"); int a= Integer.parseInt(axm.readLine()); b=y-x; if ((a == 1) && ((x>=1) && (x<12)))
  8. 8.  { System.out.println("You need to pay RM" +(b*2.00)); } else if ((a == 2) && ((x>=1)&& (x<12))) { System.out.println("You need to pay RM" +(b*1.50)); }
  9. 9.  else if ((a == 1) && (x>=12)) { System.out.println("You need to pay RM" + (b*2.00-0.10)); } else if ((a == 2) && (x>=12)) { System.out.println("You need to pay RM" + (b*1.50-0.10)); › } else { System.out.println("Invalid Entry!"); } }
  10. 10.  For an example, data that we key in is check in at 4 in the morning and check out at 5 in the evening. Our system will calculate the payment that will be paid by the customer. The system then will loop and waiting for another user.
  11. 11.  Example of the output:
  12. 12.  Another example:

×