Starting from:

$30

ECE39595-Homework 1 Solved

Using an IDE, run the simple Java program included with this homework in HW1/A/Address.java in an IDE.  NetBeans is a good one.  Take a screen shot of the screen after running the program in the IDE, and turn it in to Brightspace.

Part B Part i. 
Write a Java program that contains as its only class an Automobile class.  The class has variables to hold a vehicle identification number that can be represented as an integer, miles driven, which can be represented as a float, and the date of the last maintenance, which should be stored as a String.  A class attributes (variables) should be private.

Automobile should have a getter for each of the above values.   The getter for the maintenance date returns a String.  The statement for forming the string for the date is String str = 

“”+month+”/”+day+”/”+year; 

The constructor for automobile takes values for each of the variables, and for the month, day and year, i.e., it will take an int, float, int, int and int.

A separate class, HW1.java, contains the main function.  It should call the constructor twice to create

two Automobile objects, and then print out the values of each automobile using

System.out.println; 

Part ii. 
Take the Automobile class above and store the maintenance date as three integer values, month, date and year, instead of as a String.  The getters and setters for the date should still take three integers and return a String, respectively.

You should be able to run an unchanged HW1.java against the changed Automobile class and get the same results you got with the original Automobile class.

More products