Comsats University Islamabad Wah Campus Object Oriented Programming
Comsats University Islamabad Wah Campus Object Oriented Programming
Comsats University Islamabad Wah Campus Object Oriented Programming
Wah Campus
Submitted by:
import java.util.Scanner;
public class Car {
public String carOwner;
public class CarLearner { public String carName;
public int carPrice;
public String carModel;
public static void main(String[] args) {
Car c1=new Car(); public void setCarOwner(String a){
Car c2=new Car(); carOwner=a;
Car c3=new Car(); }
Scanner sc=new Scanner(System.in); public void setCarName(String a){
System.out.println("Enter data of first carName=a;
car."); }
System.out.print("Owner Name: "); public void setCarPrice(int a){
c1.setCarOwner(sc.nextLine()); carPrice=a;
System.out.print("Car Name: "); }
c1.setCarName(sc.nextLine()); public void setCarModel(String a){
System.out.print("Car Price: "); carModel=a;
c1.setCarPrice(sc.nextInt()); }
System.out.print("Car Model: "); public void display(){
sc.nextLine(); System.out.println(carOwner+"\t"+carName+"\
c1.setCarModel(sc.nextLine()); t"+carPrice+"\t"+carModel+"\n"+);
}
System.out.println("\nEnnter data of
second car."); }
System.out.print("Owner Name: ");
c2.setCarOwner(sc.nextLine());
System.out.print("Car Name: ");
c2.setCarName(sc.nextLine());
System.out.print("Car Price: ");
c2.setCarPrice(sc.nextInt());
System.out.print("Car Model: ");
sc.nextLine();
c2.setCarModel(sc.nextLine());
System.out.println("\
t\""+c1.carOwner+"\"");
c1.display();
System.out.println("\
t\""+c2.carOwner+"\"");
c2.display();
System.out.println("\
t\""+c3.carOwner+"\"");
c3.display();
}
}
Task 2
AccountLearner Account
}
Task 3
EmployeeLearner Employee