SlideShare a Scribd company logo
1 of 15
Download to read offline
Automobile.java
public class Automobile
{
//Declaring instance variables
private int id;
private String make;
private String model;
private String color;
private int year;
private int vin_number;
private int miles_per_gallon;
private int speed;
//Parameterized constructor
public Automobile(int id, String make, String model, String color,
int year, int vin_number, int miles_per_gallon, int speed) {
super();
//Calling the setters methods by passing the parameters
setId(id);
setYear(year);
setMiles_per_gallon(miles_per_gallon);
setMake(make);
setModel(model);
setColor(color);
setVin_number(vin_number);
setSpeed(0);
}
//Setters and getters
public int getId() {
return id;
}
public void setId(int id) {
if(id<0 || id >9999)
{
this.id=0;
}
else
{
this.id = id;
}
}
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getYear() {
return year;
}
public void setYear(int year) {
if(year<2000 || year>2017)
{
this.year=0;
}
else
{
this.year = year;
}
}
public int getVin_number() {
return vin_number;
}
public void setVin_number(int vin_number) {
this.vin_number = vin_number;
}
public int getMiles_per_gallon() {
return miles_per_gallon;
}
public void setMiles_per_gallon(int miles_per_gallon) {
if(miles_per_gallon<10 || miles_per_gallon>60)
{
this.miles_per_gallon=0;
}
else
{
this.miles_per_gallon = miles_per_gallon;
}
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed =speed;
}
//accelerate() method is used to increase the speed of the car by 5
public int accelerate()
{
setSpeed(getSpeed()+5);
return getSpeed();
}
//brake() method is used to decrease the speed of the car by 5
public int brake()
{
setSpeed(getSpeed()-5);
return getSpeed();
}
/*accelerate() method is used to increase
* the speed of the car based on the supplied speed value
*/
public int accelerate(int speed)
{
setSpeed(getSpeed()+speed);
return getSpeed();
}
/*brake() method is used to decrease
* the speed of the car based on the supplied speed value
*/
public int brake(int speed)
{
//calling the setters method
setSpeed(getSpeed()-speed);
return getSpeed();
}
}
____________________________________________
TestAutomobiles.java
public class TestAutomobiles {
public static void main(String[] args) {
System.out.println("______CAR 1______");
//Creating the Automobile Class Object by passing the parameters as input
Automobile am1=new Automobile(111,"Ford","Ford Fiesta","Black",2014,233,20,50);
//Displaying the make of the car
System.out.println("Car Make:"+am1.getMake());
//Displaying the Model of the car
System.out.println("Car Model:"+am1.getModel());
//Displaying the year
System.out.println("Car Model:"+am1.getYear());
//Displaying the Speed of the car after applying the acceleration
System.out.println("After Acceleration, Speed :"+am1.accelerate());
System.out.println("After Acceleration, Speed :"+am1.accelerate());
System.out.println("After Acceleration, Speed :"+am1.accelerate());
//Displaying the Speed of the car after applying the brakes
System.out.println("After Applying Brakes, Speed :"+am1.brake());
//Displaying the Speed of the car after applying the acceleration by passing the speed value
System.out.println("After Acceleration, Speed :"+am1.accelerate(30));
//Displaying the Speed of the car after applying the brakes by passing the speed value
System.out.println("After Applying Brakes, Speed :"+am1.brake(15));
System.out.println(" ______CAR 2______");
//Creating the Automobile Class Object by passing the parameters as input
Automobile am2=new Automobile(222,"Honda","Verna","White",2016,450,18,30);
//Displaying the make of the car
System.out.println("Car Make:"+am2.getMake());
//Displaying the Model of the car
System.out.println("Car Model:"+am2.getModel());
//Displaying the year
System.out.println("Car Model:"+am2.getYear());
//Displaying the Speed of the car after applying the acceleration
System.out.println("After Acceleration, Speed :"+am2.accelerate());
System.out.println("After Acceleration, Speed :"+am2.accelerate());
System.out.println("After Acceleration, Speed :"+am2.accelerate());
System.out.println("After Acceleration, Speed :"+am2.accelerate());
//Displaying the Speed of the car after applying the brakes
System.out.println("After Applying Brakes, Speed :"+am2.brake());
System.out.println("After Applying Brakes, Speed :"+am2.brake());
//Displaying the Speed of the car after applying the acceleration by passing the speed value
System.out.println("After Acceleration, Speed :"+am2.accelerate(40));
//Displaying the Speed of the car after applying the brakes by passing the speed value
System.out.println("After Applying Brakes, Speed :"+am2.brake(20));
System.out.println(" ______CAR 3______");
Automobile am3=new Automobile(333,"Honda","BRIO","GREY",2015,347,15,45);
//Displaying the make of the car
System.out.println("Car Make:"+am3.getMake());
//Displaying the Model of the car
System.out.println("Car Model:"+am3.getModel());
//Displaying the year
System.out.println("Car Model:"+am3.getYear());
//Displaying the Speed of the car after applying the acceleration
System.out.println("After Acceleration, Speed :"+am3.accelerate());
System.out.println("After Acceleration, Speed :"+am3.accelerate());
System.out.println("After Acceleration, Speed :"+am3.accelerate());
//Displaying the Speed of the car after applying the brakes
System.out.println("After Applying Brakes, Speed :"+am3.brake());
System.out.println("After Applying Brakes, Speed :"+am3.brake());
//Displaying the Speed of the car after applying the acceleration by passing the speed value
System.out.println("After Acceleration, Speed :"+am3.accelerate(50));
//Displaying the Speed of the car after applying the brakes by passing the speed value
System.out.println("After Applying Brakes, Speed :"+am3.brake(35));
}
}
___________________________________________
Output:
______CAR 1______
Car Make:Ford
Car Model:Ford Fiesta
Car Model:2014
After Acceleration, Speed :5
After Acceleration, Speed :10
After Acceleration, Speed :15
After Applying Brakes, Speed :10
After Acceleration, Speed :40
After Applying Brakes, Speed :25
______CAR 2______
Car Make:Honda
Car Model:Verna
Car Model:2016
After Acceleration, Speed :5
After Acceleration, Speed :10
After Acceleration, Speed :15
After Acceleration, Speed :20
After Applying Brakes, Speed :15
After Applying Brakes, Speed :10
After Acceleration, Speed :50
After Applying Brakes, Speed :30
______CAR 3______
Car Make:Honda
Car Model:BRIO
Car Model:2015
After Acceleration, Speed :5
After Acceleration, Speed :10
After Acceleration, Speed :15
After Applying Brakes, Speed :10
After Applying Brakes, Speed :5
After Acceleration, Speed :55
After Applying Brakes, Speed :20
___________________________________________Thank You
Solution
Automobile.java
public class Automobile
{
//Declaring instance variables
private int id;
private String make;
private String model;
private String color;
private int year;
private int vin_number;
private int miles_per_gallon;
private int speed;
//Parameterized constructor
public Automobile(int id, String make, String model, String color,
int year, int vin_number, int miles_per_gallon, int speed) {
super();
//Calling the setters methods by passing the parameters
setId(id);
setYear(year);
setMiles_per_gallon(miles_per_gallon);
setMake(make);
setModel(model);
setColor(color);
setVin_number(vin_number);
setSpeed(0);
}
//Setters and getters
public int getId() {
return id;
}
public void setId(int id) {
if(id<0 || id >9999)
{
this.id=0;
}
else
{
this.id = id;
}
}
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getYear() {
return year;
}
public void setYear(int year) {
if(year<2000 || year>2017)
{
this.year=0;
}
else
{
this.year = year;
}
}
public int getVin_number() {
return vin_number;
}
public void setVin_number(int vin_number) {
this.vin_number = vin_number;
}
public int getMiles_per_gallon() {
return miles_per_gallon;
}
public void setMiles_per_gallon(int miles_per_gallon) {
if(miles_per_gallon<10 || miles_per_gallon>60)
{
this.miles_per_gallon=0;
}
else
{
this.miles_per_gallon = miles_per_gallon;
}
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed =speed;
}
//accelerate() method is used to increase the speed of the car by 5
public int accelerate()
{
setSpeed(getSpeed()+5);
return getSpeed();
}
//brake() method is used to decrease the speed of the car by 5
public int brake()
{
setSpeed(getSpeed()-5);
return getSpeed();
}
/*accelerate() method is used to increase
* the speed of the car based on the supplied speed value
*/
public int accelerate(int speed)
{
setSpeed(getSpeed()+speed);
return getSpeed();
}
/*brake() method is used to decrease
* the speed of the car based on the supplied speed value
*/
public int brake(int speed)
{
//calling the setters method
setSpeed(getSpeed()-speed);
return getSpeed();
}
}
____________________________________________
TestAutomobiles.java
public class TestAutomobiles {
public static void main(String[] args) {
System.out.println("______CAR 1______");
//Creating the Automobile Class Object by passing the parameters as input
Automobile am1=new Automobile(111,"Ford","Ford Fiesta","Black",2014,233,20,50);
//Displaying the make of the car
System.out.println("Car Make:"+am1.getMake());
//Displaying the Model of the car
System.out.println("Car Model:"+am1.getModel());
//Displaying the year
System.out.println("Car Model:"+am1.getYear());
//Displaying the Speed of the car after applying the acceleration
System.out.println("After Acceleration, Speed :"+am1.accelerate());
System.out.println("After Acceleration, Speed :"+am1.accelerate());
System.out.println("After Acceleration, Speed :"+am1.accelerate());
//Displaying the Speed of the car after applying the brakes
System.out.println("After Applying Brakes, Speed :"+am1.brake());
//Displaying the Speed of the car after applying the acceleration by passing the speed value
System.out.println("After Acceleration, Speed :"+am1.accelerate(30));
//Displaying the Speed of the car after applying the brakes by passing the speed value
System.out.println("After Applying Brakes, Speed :"+am1.brake(15));
System.out.println(" ______CAR 2______");
//Creating the Automobile Class Object by passing the parameters as input
Automobile am2=new Automobile(222,"Honda","Verna","White",2016,450,18,30);
//Displaying the make of the car
System.out.println("Car Make:"+am2.getMake());
//Displaying the Model of the car
System.out.println("Car Model:"+am2.getModel());
//Displaying the year
System.out.println("Car Model:"+am2.getYear());
//Displaying the Speed of the car after applying the acceleration
System.out.println("After Acceleration, Speed :"+am2.accelerate());
System.out.println("After Acceleration, Speed :"+am2.accelerate());
System.out.println("After Acceleration, Speed :"+am2.accelerate());
System.out.println("After Acceleration, Speed :"+am2.accelerate());
//Displaying the Speed of the car after applying the brakes
System.out.println("After Applying Brakes, Speed :"+am2.brake());
System.out.println("After Applying Brakes, Speed :"+am2.brake());
//Displaying the Speed of the car after applying the acceleration by passing the speed value
System.out.println("After Acceleration, Speed :"+am2.accelerate(40));
//Displaying the Speed of the car after applying the brakes by passing the speed value
System.out.println("After Applying Brakes, Speed :"+am2.brake(20));
System.out.println(" ______CAR 3______");
Automobile am3=new Automobile(333,"Honda","BRIO","GREY",2015,347,15,45);
//Displaying the make of the car
System.out.println("Car Make:"+am3.getMake());
//Displaying the Model of the car
System.out.println("Car Model:"+am3.getModel());
//Displaying the year
System.out.println("Car Model:"+am3.getYear());
//Displaying the Speed of the car after applying the acceleration
System.out.println("After Acceleration, Speed :"+am3.accelerate());
System.out.println("After Acceleration, Speed :"+am3.accelerate());
System.out.println("After Acceleration, Speed :"+am3.accelerate());
//Displaying the Speed of the car after applying the brakes
System.out.println("After Applying Brakes, Speed :"+am3.brake());
System.out.println("After Applying Brakes, Speed :"+am3.brake());
//Displaying the Speed of the car after applying the acceleration by passing the speed value
System.out.println("After Acceleration, Speed :"+am3.accelerate(50));
//Displaying the Speed of the car after applying the brakes by passing the speed value
System.out.println("After Applying Brakes, Speed :"+am3.brake(35));
}
}
___________________________________________
Output:
______CAR 1______
Car Make:Ford
Car Model:Ford Fiesta
Car Model:2014
After Acceleration, Speed :5
After Acceleration, Speed :10
After Acceleration, Speed :15
After Applying Brakes, Speed :10
After Acceleration, Speed :40
After Applying Brakes, Speed :25
______CAR 2______
Car Make:Honda
Car Model:Verna
Car Model:2016
After Acceleration, Speed :5
After Acceleration, Speed :10
After Acceleration, Speed :15
After Acceleration, Speed :20
After Applying Brakes, Speed :15
After Applying Brakes, Speed :10
After Acceleration, Speed :50
After Applying Brakes, Speed :30
______CAR 3______
Car Make:Honda
Car Model:BRIO
Car Model:2015
After Acceleration, Speed :5
After Acceleration, Speed :10
After Acceleration, Speed :15
After Applying Brakes, Speed :10
After Applying Brakes, Speed :5
After Acceleration, Speed :55
After Applying Brakes, Speed :20
___________________________________________Thank You

More Related Content

Similar to Automobile.javapublic class Automobile {    Declaring instan.pdf

R, Scikit-Learn and Apache Spark ML - What difference does it make?
R, Scikit-Learn and Apache Spark ML - What difference does it make?R, Scikit-Learn and Apache Spark ML - What difference does it make?
R, Scikit-Learn and Apache Spark ML - What difference does it make?Villu Ruusmann
 
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdfThis is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdfbharatchawla141
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classesIntro C# Book
 
Angular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAngular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAlexey Frolov
 
Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)Kasper Reijnders
 
#includeiostream #includecmath #includestringusing na.pdf
 #includeiostream #includecmath #includestringusing na.pdf #includeiostream #includecmath #includestringusing na.pdf
#includeiostream #includecmath #includestringusing na.pdfanuradhaartjwellery
 
Classing up ES6 - Web Directions code 2015 (1)
Classing up ES6 - Web Directions code 2015 (1)Classing up ES6 - Web Directions code 2015 (1)
Classing up ES6 - Web Directions code 2015 (1)Andy Sharman
 
This is my visual studio C code how do I make it so that w.pdf
This is my visual studio C code how do I make it so that w.pdfThis is my visual studio C code how do I make it so that w.pdf
This is my visual studio C code how do I make it so that w.pdfadinathfashion1
 
package reservation; import java.util.; For Scanner Class .pdf
 package reservation; import java.util.; For Scanner Class .pdf package reservation; import java.util.; For Scanner Class .pdf
package reservation; import java.util.; For Scanner Class .pdfanitasahani11
 
cars design code power system detai.pptx
cars design code power system detai.pptxcars design code power system detai.pptx
cars design code power system detai.pptxabomoayad19309
 
Classes and Objects In C# With Example
Classes and Objects In C# With ExampleClasses and Objects In C# With Example
Classes and Objects In C# With ExampleCheezy Code
 
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdfONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdfvinodagrawal6699
 

Similar to Automobile.javapublic class Automobile {    Declaring instan.pdf (16)

R, Scikit-Learn and Apache Spark ML - What difference does it make?
R, Scikit-Learn and Apache Spark ML - What difference does it make?R, Scikit-Learn and Apache Spark ML - What difference does it make?
R, Scikit-Learn and Apache Spark ML - What difference does it make?
 
Exam2prep
Exam2prepExam2prep
Exam2prep
 
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdfThis is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classes
 
Angular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app exampleAngular2: Quick overview with 2do app example
Angular2: Quick overview with 2do app example
 
Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)Jan 2017 - a web of applications (angular 2)
Jan 2017 - a web of applications (angular 2)
 
#includeiostream #includecmath #includestringusing na.pdf
 #includeiostream #includecmath #includestringusing na.pdf #includeiostream #includecmath #includestringusing na.pdf
#includeiostream #includecmath #includestringusing na.pdf
 
Itsjustangular
ItsjustangularItsjustangular
Itsjustangular
 
Classing up ES6 - Web Directions code 2015 (1)
Classing up ES6 - Web Directions code 2015 (1)Classing up ES6 - Web Directions code 2015 (1)
Classing up ES6 - Web Directions code 2015 (1)
 
This is my visual studio C code how do I make it so that w.pdf
This is my visual studio C code how do I make it so that w.pdfThis is my visual studio C code how do I make it so that w.pdf
This is my visual studio C code how do I make it so that w.pdf
 
package reservation; import java.util.; For Scanner Class .pdf
 package reservation; import java.util.; For Scanner Class .pdf package reservation; import java.util.; For Scanner Class .pdf
package reservation; import java.util.; For Scanner Class .pdf
 
cars design code power system detai.pptx
cars design code power system detai.pptxcars design code power system detai.pptx
cars design code power system detai.pptx
 
Classes and Objects In C# With Example
Classes and Objects In C# With ExampleClasses and Objects In C# With Example
Classes and Objects In C# With Example
 
Java doc Pr ITM2
Java doc Pr ITM2Java doc Pr ITM2
Java doc Pr ITM2
 
Optional in Java 8
Optional in Java 8Optional in Java 8
Optional in Java 8
 
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdfONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
 

More from anitasahani11

2.Kernel need to be protected because non-root user execute kernel.pdf
2.Kernel need to be protected because non-root user execute kernel.pdf2.Kernel need to be protected because non-root user execute kernel.pdf
2.Kernel need to be protected because non-root user execute kernel.pdfanitasahani11
 
1.C. Fate of the blastopore becomes the mouth.2.C. Endodermis Casp.pdf
1.C. Fate of the blastopore becomes the mouth.2.C. Endodermis Casp.pdf1.C. Fate of the blastopore becomes the mouth.2.C. Endodermis Casp.pdf
1.C. Fate of the blastopore becomes the mouth.2.C. Endodermis Casp.pdfanitasahani11
 
1. a. -8 to 4 is 12 unitsb. D to B is 8 unitsc. idk what that de.pdf
1. a. -8 to 4 is 12 unitsb. D to B is 8 unitsc. idk what that de.pdf1. a. -8 to 4 is 12 unitsb. D to B is 8 unitsc. idk what that de.pdf
1. a. -8 to 4 is 12 unitsb. D to B is 8 unitsc. idk what that de.pdfanitasahani11
 
1. Confidential or privileged information cannot be denied to the co.pdf
1. Confidential or privileged information cannot be denied to the co.pdf1. Confidential or privileged information cannot be denied to the co.pdf
1. Confidential or privileged information cannot be denied to the co.pdfanitasahani11
 
The three different 3SolutionThe three different 3.pdf
The three different 3SolutionThe three different 3.pdfThe three different 3SolutionThe three different 3.pdf
The three different 3SolutionThe three different 3.pdfanitasahani11
 
Whales are mammals that breathe into the lungs. Whales contain blow .pdf
Whales are mammals that breathe into the lungs. Whales contain blow .pdfWhales are mammals that breathe into the lungs. Whales contain blow .pdf
Whales are mammals that breathe into the lungs. Whales contain blow .pdfanitasahani11
 
w12-8v6Solutionw12-8v6.pdf
w12-8v6Solutionw12-8v6.pdfw12-8v6Solutionw12-8v6.pdf
w12-8v6Solutionw12-8v6.pdfanitasahani11
 
This site provides illustrative experience in the use of Excel for d.pdf
This site provides illustrative experience in the use of Excel for d.pdfThis site provides illustrative experience in the use of Excel for d.pdf
This site provides illustrative experience in the use of Excel for d.pdfanitasahani11
 
The conch symbolizes social order, respect and power. When the boys .pdf
The conch symbolizes social order, respect and power. When the boys .pdfThe conch symbolizes social order, respect and power. When the boys .pdf
The conch symbolizes social order, respect and power. When the boys .pdfanitasahani11
 
The bone marrow is the wellspring of numerous immune and blood cells.pdf
The bone marrow is the wellspring of numerous immune and blood cells.pdfThe bone marrow is the wellspring of numerous immune and blood cells.pdf
The bone marrow is the wellspring of numerous immune and blood cells.pdfanitasahani11
 
Stanley Miller experiment explains the origin and evolution of earth.pdf
Stanley Miller experiment explains the origin and evolution of earth.pdfStanley Miller experiment explains the origin and evolution of earth.pdf
Stanley Miller experiment explains the origin and evolution of earth.pdfanitasahani11
 
service revenueSolutionservice revenue.pdf
service revenueSolutionservice revenue.pdfservice revenueSolutionservice revenue.pdf
service revenueSolutionservice revenue.pdfanitasahani11
 
public class DecimalToBinary {    public void printBinaryFormat(in.pdf
public class DecimalToBinary {    public void printBinaryFormat(in.pdfpublic class DecimalToBinary {    public void printBinaryFormat(in.pdf
public class DecimalToBinary {    public void printBinaryFormat(in.pdfanitasahani11
 
#includeiostream #includequeue #includefstream using nam.pdf
#includeiostream #includequeue #includefstream using nam.pdf#includeiostream #includequeue #includefstream using nam.pdf
#includeiostream #includequeue #includefstream using nam.pdfanitasahani11
 
Traffic intersection is a piece of transportation infrastructure wha.pdf
  Traffic intersection is a piece of transportation infrastructure wha.pdf  Traffic intersection is a piece of transportation infrastructure wha.pdf
Traffic intersection is a piece of transportation infrastructure wha.pdfanitasahani11
 
Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre Step2 .pdf
                     Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre  Step2 .pdf                     Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre  Step2 .pdf
Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre Step2 .pdfanitasahani11
 
ZnOCu2OV2O3,Ni2O3MnO .pdf
                     ZnOCu2OV2O3,Ni2O3MnO                         .pdf                     ZnOCu2OV2O3,Ni2O3MnO                         .pdf
ZnOCu2OV2O3,Ni2O3MnO .pdfanitasahani11
 
There is actually a few differences. Firstly, a p.pdf
                     There is actually a few differences. Firstly, a p.pdf                     There is actually a few differences. Firstly, a p.pdf
There is actually a few differences. Firstly, a p.pdfanitasahani11
 
Hg^2+ is soft acid and thus akin to bind to soft .pdf
                     Hg^2+ is soft acid and thus akin to bind to soft .pdf                     Hg^2+ is soft acid and thus akin to bind to soft .pdf
Hg^2+ is soft acid and thus akin to bind to soft .pdfanitasahani11
 
HCl dissociates into H+ and Cl- in solution. The .pdf
                     HCl dissociates into H+ and Cl- in solution. The .pdf                     HCl dissociates into H+ and Cl- in solution. The .pdf
HCl dissociates into H+ and Cl- in solution. The .pdfanitasahani11
 

More from anitasahani11 (20)

2.Kernel need to be protected because non-root user execute kernel.pdf
2.Kernel need to be protected because non-root user execute kernel.pdf2.Kernel need to be protected because non-root user execute kernel.pdf
2.Kernel need to be protected because non-root user execute kernel.pdf
 
1.C. Fate of the blastopore becomes the mouth.2.C. Endodermis Casp.pdf
1.C. Fate of the blastopore becomes the mouth.2.C. Endodermis Casp.pdf1.C. Fate of the blastopore becomes the mouth.2.C. Endodermis Casp.pdf
1.C. Fate of the blastopore becomes the mouth.2.C. Endodermis Casp.pdf
 
1. a. -8 to 4 is 12 unitsb. D to B is 8 unitsc. idk what that de.pdf
1. a. -8 to 4 is 12 unitsb. D to B is 8 unitsc. idk what that de.pdf1. a. -8 to 4 is 12 unitsb. D to B is 8 unitsc. idk what that de.pdf
1. a. -8 to 4 is 12 unitsb. D to B is 8 unitsc. idk what that de.pdf
 
1. Confidential or privileged information cannot be denied to the co.pdf
1. Confidential or privileged information cannot be denied to the co.pdf1. Confidential or privileged information cannot be denied to the co.pdf
1. Confidential or privileged information cannot be denied to the co.pdf
 
The three different 3SolutionThe three different 3.pdf
The three different 3SolutionThe three different 3.pdfThe three different 3SolutionThe three different 3.pdf
The three different 3SolutionThe three different 3.pdf
 
Whales are mammals that breathe into the lungs. Whales contain blow .pdf
Whales are mammals that breathe into the lungs. Whales contain blow .pdfWhales are mammals that breathe into the lungs. Whales contain blow .pdf
Whales are mammals that breathe into the lungs. Whales contain blow .pdf
 
w12-8v6Solutionw12-8v6.pdf
w12-8v6Solutionw12-8v6.pdfw12-8v6Solutionw12-8v6.pdf
w12-8v6Solutionw12-8v6.pdf
 
This site provides illustrative experience in the use of Excel for d.pdf
This site provides illustrative experience in the use of Excel for d.pdfThis site provides illustrative experience in the use of Excel for d.pdf
This site provides illustrative experience in the use of Excel for d.pdf
 
The conch symbolizes social order, respect and power. When the boys .pdf
The conch symbolizes social order, respect and power. When the boys .pdfThe conch symbolizes social order, respect and power. When the boys .pdf
The conch symbolizes social order, respect and power. When the boys .pdf
 
The bone marrow is the wellspring of numerous immune and blood cells.pdf
The bone marrow is the wellspring of numerous immune and blood cells.pdfThe bone marrow is the wellspring of numerous immune and blood cells.pdf
The bone marrow is the wellspring of numerous immune and blood cells.pdf
 
Stanley Miller experiment explains the origin and evolution of earth.pdf
Stanley Miller experiment explains the origin and evolution of earth.pdfStanley Miller experiment explains the origin and evolution of earth.pdf
Stanley Miller experiment explains the origin and evolution of earth.pdf
 
service revenueSolutionservice revenue.pdf
service revenueSolutionservice revenue.pdfservice revenueSolutionservice revenue.pdf
service revenueSolutionservice revenue.pdf
 
public class DecimalToBinary {    public void printBinaryFormat(in.pdf
public class DecimalToBinary {    public void printBinaryFormat(in.pdfpublic class DecimalToBinary {    public void printBinaryFormat(in.pdf
public class DecimalToBinary {    public void printBinaryFormat(in.pdf
 
#includeiostream #includequeue #includefstream using nam.pdf
#includeiostream #includequeue #includefstream using nam.pdf#includeiostream #includequeue #includefstream using nam.pdf
#includeiostream #includequeue #includefstream using nam.pdf
 
Traffic intersection is a piece of transportation infrastructure wha.pdf
  Traffic intersection is a piece of transportation infrastructure wha.pdf  Traffic intersection is a piece of transportation infrastructure wha.pdf
Traffic intersection is a piece of transportation infrastructure wha.pdf
 
Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre Step2 .pdf
                     Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre  Step2 .pdf                     Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre  Step2 .pdf
Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre Step2 .pdf
 
ZnOCu2OV2O3,Ni2O3MnO .pdf
                     ZnOCu2OV2O3,Ni2O3MnO                         .pdf                     ZnOCu2OV2O3,Ni2O3MnO                         .pdf
ZnOCu2OV2O3,Ni2O3MnO .pdf
 
There is actually a few differences. Firstly, a p.pdf
                     There is actually a few differences. Firstly, a p.pdf                     There is actually a few differences. Firstly, a p.pdf
There is actually a few differences. Firstly, a p.pdf
 
Hg^2+ is soft acid and thus akin to bind to soft .pdf
                     Hg^2+ is soft acid and thus akin to bind to soft .pdf                     Hg^2+ is soft acid and thus akin to bind to soft .pdf
Hg^2+ is soft acid and thus akin to bind to soft .pdf
 
HCl dissociates into H+ and Cl- in solution. The .pdf
                     HCl dissociates into H+ and Cl- in solution. The .pdf                     HCl dissociates into H+ and Cl- in solution. The .pdf
HCl dissociates into H+ and Cl- in solution. The .pdf
 

Recently uploaded

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Recently uploaded (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

Automobile.javapublic class Automobile {    Declaring instan.pdf

  • 1. Automobile.java public class Automobile { //Declaring instance variables private int id; private String make; private String model; private String color; private int year; private int vin_number; private int miles_per_gallon; private int speed; //Parameterized constructor public Automobile(int id, String make, String model, String color, int year, int vin_number, int miles_per_gallon, int speed) { super(); //Calling the setters methods by passing the parameters setId(id); setYear(year); setMiles_per_gallon(miles_per_gallon); setMake(make); setModel(model); setColor(color); setVin_number(vin_number); setSpeed(0); } //Setters and getters public int getId() { return id; } public void setId(int id) { if(id<0 || id >9999)
  • 2. { this.id=0; } else { this.id = id; } } public String getMake() { return make; } public void setMake(String make) { this.make = make; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public int getYear() { return year; } public void setYear(int year) { if(year<2000 || year>2017) { this.year=0; } else {
  • 3. this.year = year; } } public int getVin_number() { return vin_number; } public void setVin_number(int vin_number) { this.vin_number = vin_number; } public int getMiles_per_gallon() { return miles_per_gallon; } public void setMiles_per_gallon(int miles_per_gallon) { if(miles_per_gallon<10 || miles_per_gallon>60) { this.miles_per_gallon=0; } else { this.miles_per_gallon = miles_per_gallon; } } public int getSpeed() { return speed; } public void setSpeed(int speed) { this.speed =speed; } //accelerate() method is used to increase the speed of the car by 5 public int accelerate() { setSpeed(getSpeed()+5); return getSpeed(); }
  • 4. //brake() method is used to decrease the speed of the car by 5 public int brake() { setSpeed(getSpeed()-5); return getSpeed(); } /*accelerate() method is used to increase * the speed of the car based on the supplied speed value */ public int accelerate(int speed) { setSpeed(getSpeed()+speed); return getSpeed(); } /*brake() method is used to decrease * the speed of the car based on the supplied speed value */ public int brake(int speed) { //calling the setters method setSpeed(getSpeed()-speed); return getSpeed(); } } ____________________________________________ TestAutomobiles.java public class TestAutomobiles { public static void main(String[] args) { System.out.println("______CAR 1______"); //Creating the Automobile Class Object by passing the parameters as input Automobile am1=new Automobile(111,"Ford","Ford Fiesta","Black",2014,233,20,50);
  • 5. //Displaying the make of the car System.out.println("Car Make:"+am1.getMake()); //Displaying the Model of the car System.out.println("Car Model:"+am1.getModel()); //Displaying the year System.out.println("Car Model:"+am1.getYear()); //Displaying the Speed of the car after applying the acceleration System.out.println("After Acceleration, Speed :"+am1.accelerate()); System.out.println("After Acceleration, Speed :"+am1.accelerate()); System.out.println("After Acceleration, Speed :"+am1.accelerate()); //Displaying the Speed of the car after applying the brakes System.out.println("After Applying Brakes, Speed :"+am1.brake()); //Displaying the Speed of the car after applying the acceleration by passing the speed value System.out.println("After Acceleration, Speed :"+am1.accelerate(30)); //Displaying the Speed of the car after applying the brakes by passing the speed value System.out.println("After Applying Brakes, Speed :"+am1.brake(15)); System.out.println(" ______CAR 2______"); //Creating the Automobile Class Object by passing the parameters as input Automobile am2=new Automobile(222,"Honda","Verna","White",2016,450,18,30); //Displaying the make of the car System.out.println("Car Make:"+am2.getMake()); //Displaying the Model of the car System.out.println("Car Model:"+am2.getModel()); //Displaying the year
  • 6. System.out.println("Car Model:"+am2.getYear()); //Displaying the Speed of the car after applying the acceleration System.out.println("After Acceleration, Speed :"+am2.accelerate()); System.out.println("After Acceleration, Speed :"+am2.accelerate()); System.out.println("After Acceleration, Speed :"+am2.accelerate()); System.out.println("After Acceleration, Speed :"+am2.accelerate()); //Displaying the Speed of the car after applying the brakes System.out.println("After Applying Brakes, Speed :"+am2.brake()); System.out.println("After Applying Brakes, Speed :"+am2.brake()); //Displaying the Speed of the car after applying the acceleration by passing the speed value System.out.println("After Acceleration, Speed :"+am2.accelerate(40)); //Displaying the Speed of the car after applying the brakes by passing the speed value System.out.println("After Applying Brakes, Speed :"+am2.brake(20)); System.out.println(" ______CAR 3______"); Automobile am3=new Automobile(333,"Honda","BRIO","GREY",2015,347,15,45); //Displaying the make of the car System.out.println("Car Make:"+am3.getMake()); //Displaying the Model of the car System.out.println("Car Model:"+am3.getModel()); //Displaying the year System.out.println("Car Model:"+am3.getYear()); //Displaying the Speed of the car after applying the acceleration System.out.println("After Acceleration, Speed :"+am3.accelerate()); System.out.println("After Acceleration, Speed :"+am3.accelerate()); System.out.println("After Acceleration, Speed :"+am3.accelerate()); //Displaying the Speed of the car after applying the brakes
  • 7. System.out.println("After Applying Brakes, Speed :"+am3.brake()); System.out.println("After Applying Brakes, Speed :"+am3.brake()); //Displaying the Speed of the car after applying the acceleration by passing the speed value System.out.println("After Acceleration, Speed :"+am3.accelerate(50)); //Displaying the Speed of the car after applying the brakes by passing the speed value System.out.println("After Applying Brakes, Speed :"+am3.brake(35)); } } ___________________________________________ Output: ______CAR 1______ Car Make:Ford Car Model:Ford Fiesta Car Model:2014 After Acceleration, Speed :5 After Acceleration, Speed :10 After Acceleration, Speed :15 After Applying Brakes, Speed :10 After Acceleration, Speed :40 After Applying Brakes, Speed :25 ______CAR 2______ Car Make:Honda Car Model:Verna Car Model:2016 After Acceleration, Speed :5 After Acceleration, Speed :10 After Acceleration, Speed :15 After Acceleration, Speed :20 After Applying Brakes, Speed :15 After Applying Brakes, Speed :10 After Acceleration, Speed :50 After Applying Brakes, Speed :30 ______CAR 3______
  • 8. Car Make:Honda Car Model:BRIO Car Model:2015 After Acceleration, Speed :5 After Acceleration, Speed :10 After Acceleration, Speed :15 After Applying Brakes, Speed :10 After Applying Brakes, Speed :5 After Acceleration, Speed :55 After Applying Brakes, Speed :20 ___________________________________________Thank You Solution Automobile.java public class Automobile { //Declaring instance variables private int id; private String make; private String model; private String color; private int year; private int vin_number; private int miles_per_gallon; private int speed; //Parameterized constructor public Automobile(int id, String make, String model, String color, int year, int vin_number, int miles_per_gallon, int speed) { super(); //Calling the setters methods by passing the parameters setId(id); setYear(year); setMiles_per_gallon(miles_per_gallon);
  • 9. setMake(make); setModel(model); setColor(color); setVin_number(vin_number); setSpeed(0); } //Setters and getters public int getId() { return id; } public void setId(int id) { if(id<0 || id >9999) { this.id=0; } else { this.id = id; } } public String getMake() { return make; } public void setMake(String make) { this.make = make; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } public String getColor() { return color; }
  • 10. public void setColor(String color) { this.color = color; } public int getYear() { return year; } public void setYear(int year) { if(year<2000 || year>2017) { this.year=0; } else { this.year = year; } } public int getVin_number() { return vin_number; } public void setVin_number(int vin_number) { this.vin_number = vin_number; } public int getMiles_per_gallon() { return miles_per_gallon; } public void setMiles_per_gallon(int miles_per_gallon) { if(miles_per_gallon<10 || miles_per_gallon>60) { this.miles_per_gallon=0; } else { this.miles_per_gallon = miles_per_gallon; } } public int getSpeed() {
  • 11. return speed; } public void setSpeed(int speed) { this.speed =speed; } //accelerate() method is used to increase the speed of the car by 5 public int accelerate() { setSpeed(getSpeed()+5); return getSpeed(); } //brake() method is used to decrease the speed of the car by 5 public int brake() { setSpeed(getSpeed()-5); return getSpeed(); } /*accelerate() method is used to increase * the speed of the car based on the supplied speed value */ public int accelerate(int speed) { setSpeed(getSpeed()+speed); return getSpeed(); } /*brake() method is used to decrease * the speed of the car based on the supplied speed value */ public int brake(int speed) { //calling the setters method
  • 12. setSpeed(getSpeed()-speed); return getSpeed(); } } ____________________________________________ TestAutomobiles.java public class TestAutomobiles { public static void main(String[] args) { System.out.println("______CAR 1______"); //Creating the Automobile Class Object by passing the parameters as input Automobile am1=new Automobile(111,"Ford","Ford Fiesta","Black",2014,233,20,50); //Displaying the make of the car System.out.println("Car Make:"+am1.getMake()); //Displaying the Model of the car System.out.println("Car Model:"+am1.getModel()); //Displaying the year System.out.println("Car Model:"+am1.getYear()); //Displaying the Speed of the car after applying the acceleration System.out.println("After Acceleration, Speed :"+am1.accelerate()); System.out.println("After Acceleration, Speed :"+am1.accelerate()); System.out.println("After Acceleration, Speed :"+am1.accelerate()); //Displaying the Speed of the car after applying the brakes System.out.println("After Applying Brakes, Speed :"+am1.brake()); //Displaying the Speed of the car after applying the acceleration by passing the speed value System.out.println("After Acceleration, Speed :"+am1.accelerate(30)); //Displaying the Speed of the car after applying the brakes by passing the speed value System.out.println("After Applying Brakes, Speed :"+am1.brake(15));
  • 13. System.out.println(" ______CAR 2______"); //Creating the Automobile Class Object by passing the parameters as input Automobile am2=new Automobile(222,"Honda","Verna","White",2016,450,18,30); //Displaying the make of the car System.out.println("Car Make:"+am2.getMake()); //Displaying the Model of the car System.out.println("Car Model:"+am2.getModel()); //Displaying the year System.out.println("Car Model:"+am2.getYear()); //Displaying the Speed of the car after applying the acceleration System.out.println("After Acceleration, Speed :"+am2.accelerate()); System.out.println("After Acceleration, Speed :"+am2.accelerate()); System.out.println("After Acceleration, Speed :"+am2.accelerate()); System.out.println("After Acceleration, Speed :"+am2.accelerate()); //Displaying the Speed of the car after applying the brakes System.out.println("After Applying Brakes, Speed :"+am2.brake()); System.out.println("After Applying Brakes, Speed :"+am2.brake()); //Displaying the Speed of the car after applying the acceleration by passing the speed value System.out.println("After Acceleration, Speed :"+am2.accelerate(40)); //Displaying the Speed of the car after applying the brakes by passing the speed value System.out.println("After Applying Brakes, Speed :"+am2.brake(20)); System.out.println(" ______CAR 3______"); Automobile am3=new Automobile(333,"Honda","BRIO","GREY",2015,347,15,45); //Displaying the make of the car System.out.println("Car Make:"+am3.getMake());
  • 14. //Displaying the Model of the car System.out.println("Car Model:"+am3.getModel()); //Displaying the year System.out.println("Car Model:"+am3.getYear()); //Displaying the Speed of the car after applying the acceleration System.out.println("After Acceleration, Speed :"+am3.accelerate()); System.out.println("After Acceleration, Speed :"+am3.accelerate()); System.out.println("After Acceleration, Speed :"+am3.accelerate()); //Displaying the Speed of the car after applying the brakes System.out.println("After Applying Brakes, Speed :"+am3.brake()); System.out.println("After Applying Brakes, Speed :"+am3.brake()); //Displaying the Speed of the car after applying the acceleration by passing the speed value System.out.println("After Acceleration, Speed :"+am3.accelerate(50)); //Displaying the Speed of the car after applying the brakes by passing the speed value System.out.println("After Applying Brakes, Speed :"+am3.brake(35)); } } ___________________________________________ Output: ______CAR 1______ Car Make:Ford Car Model:Ford Fiesta Car Model:2014 After Acceleration, Speed :5 After Acceleration, Speed :10 After Acceleration, Speed :15 After Applying Brakes, Speed :10 After Acceleration, Speed :40 After Applying Brakes, Speed :25
  • 15. ______CAR 2______ Car Make:Honda Car Model:Verna Car Model:2016 After Acceleration, Speed :5 After Acceleration, Speed :10 After Acceleration, Speed :15 After Acceleration, Speed :20 After Applying Brakes, Speed :15 After Applying Brakes, Speed :10 After Acceleration, Speed :50 After Applying Brakes, Speed :30 ______CAR 3______ Car Make:Honda Car Model:BRIO Car Model:2015 After Acceleration, Speed :5 After Acceleration, Speed :10 After Acceleration, Speed :15 After Applying Brakes, Speed :10 After Applying Brakes, Speed :5 After Acceleration, Speed :55 After Applying Brakes, Speed :20 ___________________________________________Thank You