Java Programs- Methods and Constructors
Java Programs- Methods and Constructors
1) Classname- Bank
Instance variables- cname, acno, bal, ttype
memeber methods: input(), deposit(int amt), withdraw(int amt) [minimum
balance of 500 rupees to be there], showBalance(), display()
2) Classname- PaySlip
Instance variables- ename, sal, da [15%], hra [10%], pf [8%], fsal, ptax
Memeber methods: inputData(), calculation(), findTax(), output()
fsal= sal+da+hra-pf-ptax
Net Salary Tax%
10000-25000 12%
25001-55000 15%
55001-90000 18%
Above 90000 20%
3) Classname- Products
Instance variables- pname,price, qty, totalamt, dis
Memeber methods: readData(), calcData() -> totalamt= qty*price, show()
Totalamt Disc%
Upto 5000 0%
5001 to 10000 10%
10001 to 25000 15%
25001 to 50000 20%
Above 50000 25%
1) classname- MovieMagic
Inst: year, title, rating, lang, tamt, ramt, samt, no.t
MM: default constructor, findAmt(), input(), display()
Rating Print Tamt
0.0- 2.0 Flop 200
2.1-3.4 Semi Hit 350
3.5-4.5 Hit 500
4.6-5.0 Blockbuster 900
2) Classname- RailwayTicket
Inst: name, mobno, coach, amt, famt, not
MM: default and parameterized constructor, price(), display()
Coach Amt/Ticket
First AC 1200
Second AC 1100
Third AC 1000
Sleeper 900
General 700
3) Classname- Travels
Inst: cname, taxino, dist, ttl
MM: default constructor, input method, findTotal(), display()
Dist Rate/km
First 10 25
Next 20 20
Next 40 18
Above 70 15
4) Classname- Library
Inst: cname, bname, author, noday, fine, cno
MM: default and parameterized constructor, calculate(), display()
Nodays Rate/day
Less than 5 0
5-10 1.5
11-15 3.5
More than 15 5