import java.util.Scanner;
public class Lab6
{
public static void main(String[] args)
{
//declare variables we need
//declare 2 String variables make and model
String make, model;
//declare 1 int variable year
int year;
//get the information of a car from input
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter make of your car: ");
//Take the input from the user using next()
// and assign it to <make> variable
make = keyboard.nextLine();
System.out.println();
System.out.print("Enter model of your car: ");
//Take the input from the user using next()
//and assign it to <model> variable
model = keyboard.next();
System.out.println();
System.out.print("Enter year of the car: ");
//Take the input from the user using nextInt()
//and assign it to <year> variable
year = keyboard.nextInt();
System.out.println();
//declare a new object called myCar for the class Car;
Car myCar = new Car(make, model, year);
// in order to print the year, make and model of the object Car you just
created.
System.out.println("Your car is a " + myCar.getYear() +" "+
myCar.getMake() + " " + myCar.getModel());
//get the age of the car
System.out.println("Your car is " + myCar.getAgeOfCar(2016) + " years
old");
}
}
Powered by TCPDF (www.tcpdf.org)
/*-----------------------------------------
// AUTHOR: CSE 110 TA
// FILENAME: Lab6.java
// SPECIFICATION: Driver class for creating and object of Car class and invoking
Car class methods.
// FOR: CSE 110, Lab #6
// TIME SPENT: 30 minutes
//---------------------------------------*/