Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and code a class called Date that includes two integer instance variables

ID: 3646292 • Letter: D

Question

Design and code a class called Date that includes two integer instance variables, day and year, and a String variable called month. Include a parameterized constructor, toString, and equals method.

Design and code a class called Car that includes the following instance variables: double dealerCost, integer idNumber, Date dateArrived, integer modelYear, and String makeModel. You should have a parameterized constructor, toString, and equals method (have the same modelYear, dateArrived, and makeModel).

Design and code a class called SoldCar that is derived from Car. Add the instance variables of double price, String customer, and Date dateSold. Include two constructor methods

Explanation / Answer

import java.util.Scanner; public class Assignment2 { public static void main(String[] args) { //Create scanner object to obtain input from user Scanner input = new Scanner (System.in); int MonthNum; //To hold the month from user input int Year; //To hold the year int numDays; String Month; System.out.print("Please enter the Month #"); MonthNum = input.nextInt(); System.out.print("Please enter the Year"); Year = input.nextInt(); if (MonthNum == 2) { if ( (Year % 4 == 0) && (Year % 400 == 0) && !(Year % 100 == 0) ) numDays = 29; else numDays = 28; } else if (MonthNum == 1 || MonthNum == 3 || MonthNum == 5 || MonthNum == 7 || MonthNum == 8 || MonthNum == 10 || MonthNum == 12) numDays = 31; else numDays = 30; if (MonthNum == 1) Month = "January"; else if (MonthNum == 2) Month = "Feburary"; else if (MonthNum == 3) Month = "March"; else if (MonthNum == 4) Month = "April"; else if (MonthNum == 5) Month = "May"; else if (MonthNum == 6) Month = "June"; else if (MonthNum == 7) Month = "July"; else if (MonthNum == 8) Month = "August"; else if (MonthNum == 9) Month = "September"; else if (MonthNum == 10) Month = "October"; else if (MonthNum == 11) Month = "November"; else if (MonthNum == 12) Month = "December"; System.out.println(Month + " " + Year " has " + numDays "." ); System.out.println(Month); System.out.println(numDays); }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote