public class Vehicle {
public String type;
public String make;
public String color;
public int year;
public void displayType(){
System.out.println("Your vehicle is of type :"+ type);
}
public void displayMake(){
System.out.println("It was made by :"+ make);
}
public void displayColor(){
System.out.println("Wow it's color is "+ color);
}
public void displayYear(){
if (year<2007){
System.out.println("Your vehicle is old model");
} else{
System.out.println("wow you own a latest model of vehicle");
}
}
}
public String type;
public String make;
public String color;
public int year;
public void displayType(){
System.out.println("Your vehicle is of type :"+ type);
}
public void displayMake(){
System.out.println("It was made by :"+ make);
}
public void displayColor(){
System.out.println("Wow it's color is "+ color);
}
public void displayYear(){
if (year<2007){
System.out.println("Your vehicle is old model");
} else{
System.out.println("wow you own a latest model of vehicle");
}
}
}
---------------------------------------------------------------
import java.util.Scanner;
public class VehicleImp {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Vehicle Vehicle= new Vehicle();
System.out.print("What is the type of the vehicle: ");
String type = input.next();
System.out.print("What Brand is the vehicle: ");
String make = input.next();
System.out.print("What is the color of the vehicle: ");
String color = input.next();
System.out.print("What year was it made: ");
int year = input.nextInt();
Vehicle.type = (type);
Vehicle.make = (make);
Vehicle.color = (color);
Vehicle.year = (year);
Vehicle.displayType();
Vehicle.displayMake();
Vehicle.displayColor();
Vehicle.displayYear();
}
}
No comments:
Post a Comment