I will mark brainliest to those who give me the correct answer also i will follow him/her
Q2) Design a class called Electric_Bill with following instance variable
Instance variable
String Name
int units
Int bill
Methods
Electric_biil() – Default constructor
Void input() – Input name and units consumed by customer
Void calculate()
Units Rate
First 100 units 5/-
Next 200 units 10/-
Next 200 Units 12/-
Above 500 units 15/-
Void print()
Print name ,units and bill to be paid by customer
Answers
Answer:
mate i have given the correct answer but its always appearing like this
Explanation:
<div id="answer1" class="html_text" data-lang="english"><p>import java.io.*;<br>class ElectricBill {<br>String n;<br>int units;<br>double bill ;<br>void accept() throws IOException {<br>BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));<br>System.out.print(“Name of the customer = “);<br>n = reader.readLine( );<br>System.out.print( “Number of units consumed = “);<br>String un = reader. readLine( );<br>units=Integer .parselnt(un);<br>}<br>void calculate!) {<br>if(units < = 100)<br>bill = 2.00*units;<br>if(units< =300) bill = 3.00*units; if (units > 300)<br>bill = 5.00*units;<br>}<br>void print( ) {<br>System.out.println(“Naine of the customer:” +n);<br>System.out.println(“Number of units consumed:” +units);<br>System.out.println(“Bill amount:” + bill);<br>}<br>public static void main(String argsQ) throws IO<br>Exception { ElectricBill eb = new ElectricBill( );<br>eb. accept!);<br>eb.calculate();<br>}<br>}</p></div>