Advertisement
oona

Lesson 15 brown

Oct 9th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. /**
  2. * @(#)billingsystem.java
  3. *//this program is for using a simple calculator for 5 functions
  4. *//the while statement is the user's choice whether he/she wants to continue
  5. *
  6. @author
  7. *
  8. @version 1.00 2013/10/4 */
  9.  
  10. public class billingsystem
  11. {
  12.  
  13. public static void main(String[] args)
  14. {
  15. int ID;
  16. int amount;
  17. double total = 0;
  18. char more = 'y';
  19. double billTotal = 0;
  20.  
  21. while(more =​=​ 'y')/​/​until n is entered
  22. {
  23. System.out.println("What would you like to buy?");
  24. System.out.println("[1001)soda | 1002)chips | 1003)candy/​chocolate | 1004)pizza]");
  25. ID =​ TextIO.getInt(); /​/​accept choice as integer
  26.  
  27. System.out.println("How many of these do you want?");
  28. amount = TextIO.getInt();
  29.  
  30. if(ID == 1001)
  31. {
  32. total = amount*9.90;
  33. }
  34. if(ID == 1002)
  35. {
  36. total = amount*14.75;
  37. }
  38. if(ID == 1003)
  39. {
  40. total = amount*19.60;
  41. }
  42. if(ID == 1004)
  43. {
  44. total = amount*35.50;
  45. }
  46.  
  47. System.out.println("Do you want more?");
  48. System.out.println("[y | n]");
  49. more =​ TextIO.getChar(); /​/​accept choice as character
  50.  
  51. if(more == 'n')
  52. {
  53. billTotal = total + 3.45;
  54.  
  55. System.out.println("Your total is " + billTotal + " DKK");
  56.  
  57. }//class ends
  58.  
  59. }//while ends here
  60.  
  61. }//class ends here
  62.  
  63.  
  64.  
  65.  
  66. }//program ends here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement