Guest User

Untitled

a guest
Sep 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class EB
  4. {
  5. int consumerno;
  6. String consumername;
  7. int prev_month_reading;
  8. int curr_month_reading;
  9. int type_EB_connection;
  10. int usage;
  11. double billamount=0;
  12. void display()
  13. {
  14. System.out.println("Consumer No"+" "+consumerno);
  15. System.out.println("Consumer Name"+" "+consumername);
  16. System.out.println("EB usage"+" "+usage);
  17. System.out.println("Amount to be paid"+" "+billamount);
  18.  
  19. }
  20. }
  21. public class EBBill {
  22.  
  23.  
  24. public static void main(String[] args) {
  25.  
  26. EB e=new EB();
  27. Scanner s=new Scanner(System.in);
  28. System.out.println("Enter the consumer number");
  29. e.consumerno=s.nextInt();
  30. System.out.println("Enter the consumer name");
  31. e.consumername=s.next();
  32. System.out.println("Enter the previous month reading in units");
  33. e.prev_month_reading=s.nextInt();
  34. System.out.println("Enter the current month reading in units");
  35. e.curr_month_reading=s.nextInt();
  36. System.out.println("Enter the type of EB Connection press 1 or 2.... 1.domestic 2.commercial");
  37. e.type_EB_connection=s.nextInt();
  38. e.usage =e.curr_month_reading-e.prev_month_reading;
  39. e.billamount=0;
  40. switch(e.type_EB_connection)
  41. {
  42. case 1:
  43. if(e.usage<=100)
  44. {
  45. e.billamount=e.usage*1;
  46. e.display();
  47. }
  48. else if(e.usage>100 & e.usage<=200)
  49. {
  50. e.billamount=e.usage*2.50;
  51. e.display();
  52. }
  53. else if(e.usage>200 & e.usage<=500)
  54. {
  55. e.billamount=e.usage*4;
  56. e.display();
  57. }
  58. else
  59. {
  60. e.billamount=e.usage*6;
  61. e.display();
  62. }
  63. break;
  64. case 2:
  65. if(e.usage<=100)
  66. {
  67. e.billamount=e.usage*2;
  68. e.display();
  69. }
  70. else if(e.usage>100 & e.usage<=200)
  71. {
  72. e.billamount=e.usage*4.50;
  73. e.display();
  74. }
  75. else if(e.usage>200 & e.usage<=500)
  76. {
  77. e.billamount=e.usage*6;
  78. e.display();
  79. }
  80. else
  81. {
  82. e.billamount=e.usage*7;
  83. e.display();
  84. }
  85. break;
  86. default:
  87. System.out.println("Type of Connection is in valid.");
  88. System.out.println("Enter the type of EB Connection press 1 or 2.... 1.domestic 2.commercial");
  89. }
  90.  
  91.  
  92. }
  93.  
  94. }
Add Comment
Please, Sign In to add comment