











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












class main { public static void main(String[] args) { Computer PC = new Computer(); Laptop LAP = new Laptop(); System.out.println("Computer's Details"); PC.display(); System.out.println(); System.out.println("Laptop's Details"); LAP.displayL(); } } class Computer { int wordsizeinbits; int memorysizeinmegabytes; int storagesizeinmegabytes; float speedinmegahertz;
public Computer(){ wordsizeinbits = 200; memorysizeinmegabytes = 3000; storagesizeinmegabytes = 4000; speedinmegahertz = 3.33f; } void display(){ System.out.println("Word Size In Bits : " + wordsizeinbits); System.out.println("Memory Size In Megabytes : " + memorysizeinmegabytes); System.out.println("Storage Size In Megabytes : " + storagesizeinmegabytes); System.out.println("Speed In Megahertz : " + speedinmegahertz); } } class Laptop extends Computer { int length; int width; int height; int weight; public Laptop(){ length= 15; width = 10; height = 5; weight = 3; wordsizeinbits = 300; memorysizeinmegabytes = 15000; storagesizeinmegabytes = 4000; speedinmegahertz = 280; } void displayL(){ System.out.println("Length : " + length); System.out.println("Width : " + width); System.out.println("Height : " + height);
CH.Withdrawfrombalance(9000); System.out.println(); CH.Deposittobalance(4000); System.out.println(); SavingsAccount sa = new SavingsAccount(99,"Rehman",200000.0F); System.out.println("CheckingAccount"); sa.Withdrawfrombalance(2000); System.out.println(); sa.Deposittobalance(10000); System.out.println(); } } class SavingsAccount extends BankAccount { public SavingsAccount(long AccountNumber, String AccountHolderName, float Balance) { super(AccountNumber, AccountHolderName, Balance); } public void Withdrawfrombalance(float Cashwithdraw){ System.out.println("balance= "+Balance); System.out.println("Cash Withdraw = "+Cashwithdraw); if (Cashwithdraw<=Balance){ Balance=Balance-Cashwithdraw; System.out.println("New Balance = "+Balance); } else { System.out.println("Withdraw amount should not be greater than Balance"); }
public void Deposittobalance(float Cashdeposit){ System.out.println("Balance= "+Balance); System.out.println("Cash Deposit= "+Cashdeposit); Balance=Balance+Cashdeposit; System.out.println("New Balance = "+Balance); } } class CheckingAccount extends BankAccount { public CheckingAccount(long AccountNumber,String AccountHolderName,float Balance) { super(AccountNumber,AccountHolderName,Balance); } public void Withdrawfrombalance(float Cashwithdraw) { float Overdraft; float Overdraftlimit = 1000; System.out.println("Balance = " + Balance); System.out.println("Cash Withdraw = " + Cashwithdraw); if (Cashwithdraw > Balance){ Overdraft = Cashwithdraw-Balance; if (Overdraft>Overdraftlimit){ System.out.println("Over Draft Limit Exceeded"); System.out.println("Over Draft Limit = " +Overdraftlimit); } else { Balance = Balance-Cashwithdraw; System.out.println("Over Draft = " + Overdraft); System.out.println("New Balance = "+Balance);
import java.util.Scanner; public class main { public static void main(String[] args) { String TiTlE; float PrIcE; int PageCount; float PlayingTimeInMinutes; BoOK b=new BoOK(); TiTlE T=new Tape(); Scanner sc = new Scanner(System.in);
System.out.println("Enter Title For Book"); TiTlE = sc.next(); b.setTitle(TiTlE); System.out.println("Enter Price For Book"); PrIcE = sc.nextFloat(); b.setprice(PrIcE); System.out.println("Enter Page Count For Book"); PageCount = sc.nextInt(); b.setPageCount(PageCount); System.out.println("Enter Title For Tape"); TiTlE = sc.next(); t.setTitle(TiTlE); System.out.println("Enter Price For Tape"); PrIcE= sc.nextFloat(); T.setprice(PrIcE); System.out.println("Enter Playing Time In Minutes For Tape"); PlayingTimeInMinutes = sc.nextFloat(); T.setplayingtimeinminutes(PlayingTimeInMinutes); System.out.println("Title of Book : " + b.getTiTlE()); System.out.println("Price of Book : " + b.getPrice()); System.out.println("Page Count of Book : " + b.getPageCount()); System.out.println("Title of Tape : " + T.getTiTlE()); System.out.println("Price of Tape : " + T.getPrice()); System.out.println("Playing Time In Minutes of Tape : " + T.getPlayingTimeInMinutes()); } } public class publication {
public void setPageCount(int PageCount){ this.PageCount=PageCount; } public int getpagecount(){ return PageCount; } }
import java.util.Scanner; public class main { public static void main(String[] args) { String ShapeName; float Base; float Height; Trigon Tri1=new Trigon(); Trigon Tri2=new Trigon("Threeangle",10.0F,20.0F); Trigon Tri3=new Trigon(); System.out.println("1st Object"); System.out.println("Shape Name:" +Tri1.ShapeName); Tri1.displayarea(); System.out.println("2nd Object"); System.out.println("Shape Name:" +Tri2.ShapeName); Tri2.displayarea(); System.out.println("3rd Object"); Scanner sc=new Scanner(System.in); System.out.println("Enter Shape Name"); ShapeName=sc.next();
Tri3.setShapeName(ShapeName); System.out.println("Enter Base"); Base=sc.nextFloat(); Tri3.setBase(Base); System.out.println("Enter Height"); Height=sc.nextFloat(); Tri3.setHeight(Height); System.out.println("Shape Name:" +Tri3.getShapeName()); Tri3.displayarea(); } } class geometricshape { protected String ShapeName; public void setShapeName(String ShapeName){ this.ShapeName = ShapeName; } public String getShapeName(){ return ShapeName; } } class Trigon extends geometricshape { private float Base; private float Height; float Area; public Trigon(){
import java.util.Scanner; public class main { public static void main(String[] args) { int HoUrS; HoUrLyemployee hr=new HoUrLyemployee("Rizwan ka bacha",343,12001); permanentemployee pe=new permanentemployee("Rizwan", 200 ,23447); Scanner sc = new Scanner(System.in); System.out.println("Income of Permanent Employees"); System.out.println("Enter Hours for Hourly Employees"); HoUrS=sc.nextInt();
hr.calculatetheHoUrLyincome(HoUrS); System.out.println("\nIncome of Permanent Employees"); pe.calculatetheincome(); } } class permanentemployee extends employee { public permanentemployee(String name, int empid, int HoUrLyincome){ this.name=name; this.empid=empid; this.HoUrLyincome=HoUrLyincome; } void calculatetheincome(){ int HoUrS= 654; int income = 870; float totalincome; totalincome=income*HoUrS; System.out.println("Name : "+name); System.out.println("Employee ID : "+empid); System.out.println("Total Income for Permanent Employee : "+totalincome); } } class HoUrLyemployee extends employee { public HoUrLyemployee(String name, int empid, int HoUrLyincome){ this.name=name; this.empid=empid;
public class main { public static void main(String[] args) { CurrentAccount CA=new CurrentAccount(); SavingsAccount sa=new SavingsAccount(); System.out.println("Current Account"); CA.BalanceInquiry(); CA.Amountwithdraw(30000); CA.Amountdeposit(); System.out.println(); System.out.println("Saving Account"); sa.BalanceInquiry(); sa.Amountwithdraw(5000);
sa.Amountdeposit(); } } class SavingsAccount extends BankAccount { public SavingsAccount(){ AccountId = 100; Balance = 30000; } public void Amountwithdraw(int Cashwithdraw){ System.out.println("Cash Withdraw = "+Cashwithdraw); int RemainingBalance; RemainingBalance=Balance-Cashwithdraw; if (RemainingBalance<10000){ System.out.println("While withdrawing from Current Account, the minimum balance should be less than Rs. 5000"); } else{ Balance=Balance-Cashwithdraw; System.out.println("New Balance = "+Balance); } } public void Amountdeposit(){ int Cashdeposit=376000; System.out.println("Cash Deposit = "+Cashdeposit); Balance=Balance+Cashdeposit; System.out.println("New Balance = "+Balance);
class BankAccount { int AccountId; int Balance; public void BalanceInquiry(){ System.out.println("Account ID : "+AccountId); System.out.println("Balance : "+Balance); } }