Professional Documents
Culture Documents
SUBMITTED TO:
MAM SNEHA AMIR
SOLUTION CODE:
import java.util.Scanner;
public class student{
String studentname;
String fathername;
String regnumber;
int age;
double cgpa;
int rollno;
RUNNER FILE:
import java.util.Scanner;
obj.studentname="Shayan";
obj.fathername="Zameer Ahmad";
obj.regnumber ="SP21bcs088";
obj.age = 20;
obj.cgpa=3.00;
obj.rollno = 88;
obj.display();
Lab Task 2
Time is an intangible concept. Analyze the concept and identify the data members
and methods that should be included in Time class.
SOLUTION CODE:
}
}
RUNNER FILE:
import java.util.Scanner;
public class runnertime{
public static void main(String[] args) {
obj1.hours =2;
obj1.minutes=25;
obj1.seconds= 53;
obj1.display();
}
}
Lab Task 3
Car is an object that helps us in transportation. Analyze the concept and
identify the data members and methods that should be included in Car class.
SOLUTION CODE:
String carname;
int model;
int enginenumber;
double enginecapacity;
String companyname;
public void display(){
System.out.println("car name is "+ carname);
System.out.println("model number is "+ model);
System.out.println("engine number is "+ enginenumber);
System.out.println("engine capacity is "+ enginecapacity);
System.out.println("company name is "+ companyname);
}
RUNNER FILE:
import java.util.Scanner;
System.out.println("*****************************");
System.out.println("NEXT QUESTION");
System.out.println("ENTER CARNAME");
obj2.carname= input.next();
System.out.println("ENTER MODEL Number ");
obj2.model= input.nextInt();
System.out.println("ENTER ENGINE NUMBER");
obj2.enginenumber= input.nextInt();
System.out.println("ENTER ENGINE CAPACITY");
obj2.enginecapacity= input.nextDouble();
System.out.println("ENTER COMPANY NAME");
obj2.companyname= input.next();
}
Lab Task 4
Rectangle is an object that represents a specific shape. Analyze the concept and
identify the data members and methods that should be included in Rectangle class.
SOLUTION CODE:
class rectangle{
double length;
double breath;
String colour;
RUNNER FILE:
import java.util.Scanner;
public class runnerrectangle{
public static void main(String[] args) {
System.out.println("*****************************");
System.out.println("NEXT QUESTION");
obj3.display();
System.out.println("AREA IS AS FOLLOW");
System.out.println(obj3.area(20.2,2.0));
}
}
Lab Task 5
Distance is an object that represents a specific distance in feet and inches. Analyze
the concept and identify the data members and methods that should be included in
Distance class.
SOLUTION CODE:
class distance{
double distanceinkm;
double distanceinfeet;
double distanceinmeter;
double distanceininches;
double distanceinmiles;
obj4.distanceinkm = 43.0;
obj4.distanceinmeter = 23000.0;
obj4.distanceinfeet = 2543.0;
obj4.distanceinmiles = 9.0;
obj4.distanceininches = 247563465837.0;
obj4.display();
}
}
Lab Task 6
SOLUTION CODE:
class point{
double pwxaxis;
double pwyaxis;
double pwzaxis;
import java.util.Scanner;
}
}
Lab Task 7
Circle is an object that represents a specific shape. Analyze the concept and identify
the data members and methods that should be included in Circle class.
SOLUTION CODE:
class circle{
double radius;
String colour;
RUNNER FILE:
import java.util.Scanner;
public class runnercircle{
public static void main(String[] args) {
System.out.println();
obj6.display();