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

Java Object Oriented Programming: The Program consists of three classes. The Sup

ID: 665469 • Letter: J

Question

Java Object Oriented Programming:

The Program consists of three classes. The Super class (Main Class) and two sub-classes. The Superclass creates 5 car objects and saves details such as car company, car model and year built (For all 5 cars).

The second class (Sub-class) saves the dealer address, and zip code (For all 5 cars).

The third (Sub-class) saves the color, type of car (Hybrid, sports etc.) for all 5 cars.

The Main Function displays a menu that displays the info from each class.

Example of the Menu;

Type The number

1. Displays all the Car models

2. Displays the address of all the car dealer addresses

3. Display all different colors

4. Displays all the info

(If the User types 1, it will display all the car models and if the User types 3 it will display all the different car colors and so on ...)

Explanation / Answer

import java.io.*;

import java.util.*;

class Cars
{
   public static void main(String args[])
   {
       String[] car={"hi","hello"};
       System.out.println(car[0]);
       Scanner sc=new Scanner(System.in);
       Carsmodel cm=new Carsmodel();
       Dealer d=new Dealer();
       Type t=new Type();
       while(true)
       {
           System.out.println(" ============================");
           System.out.println(" MENU");
           System.out.println(" ============================");
           System.out.println(" 1. Car Models");
           System.out.println(" 2. Dealer Addresss");
           System.out.println(" 3. Car Colors");
           System.out.println(" 4. Display Info");
           System.out.println(" 5. Quit");
           System.out.println(" ============================");  
           System.out.println(" Enter your option");
           int ch=sc.nextInt();
           switch (ch)
           {
               case 1:
               System.out.println("=======================");
               System.out.println(" CAR MODELS");
               System.out.println("=======================");
               System.out.println(" "+cm.car1[1]);
               System.out.println(" "+cm.car2[1]);
               System.out.println(" "+cm.car3[1]);
               System.out.println(" "+cm.car4[1]);
               System.out.println(" "+cm.car5[1]);
               System.out.println("=======================");
               break;
               case 2:
               System.out.println("===================================");
               System.out.println("| DEALER DETAILS       |");
               System.out.println("===================================");
               System.out.println("| ZIP CODE    |   ADDESSS |");
               System.out.println("===================================");
               System.out.println(" "+d.d1[1]+" | "+d.d1[0]);
               System.out.println(" "+d.d2[1]+" | "+d.d2[0]);
               System.out.println(" "+d.d3[1]+" | "+d.d3[0]);
               System.out.println(" "+d.d4[1]+" | "+d.d4[0]);
               System.out.println(" "+d.d5[1]+" | "+d.d5[0]);
               System.out.println("===================================");
               break;
               case 3:
               System.out.println("===================================");
               System.out.println("| CAR COLORS   |");
               System.out.println("===================================");
               System.out.println("| MODEL    |   COLOR |");
               System.out.println("===================================");
               System.out.println(" "+cm.car1[1]+" | "+t.t1[0]);
               System.out.println(" "+cm.car2[1]+" | "+t.t2[0]);
               System.out.println(" "+cm.car3[1]+" | "+t.t3[0]);
               System.out.println(" "+cm.car4[1]+"| "+t.t4[0]);
               System.out.println(" "+cm.car5[1]+" | "+t.t5[0]);
               System.out.println("===================================");
               break;
               case 4:
               System.out.println("====================================================================");
               System.out.println("COMPANY | MODEL | YEAR|DEAL_ADDRES|ZIPCODE|COLOR | TYPE | SPARES");
               System.out.println("====================================================================");
               System.out.println(cm.car1[0]+" |"+cm.car1[1]+" |"+cm.car1[2]+" | "+d.d1[0]+" |"+d.d1[1]+" |"+t.t1[0]+" | "+t.t1[1]+"| "+t.t1[2]);
               System.out.println(cm.car2[0]+" |"+cm.car2[1]+" |"+cm.car2[2]+" | "+d.d2[0]+" |"+d.d2[1]+" |"+t.t2[0]+"| "+t.t2[1]+"| "+t.t2[2]);
               System.out.println(cm.car3[0]+"|"+cm.car3[1]+" |"+cm.car3[2]+" | "+d.d3[0]+" |"+d.d3[1]+" |"+t.t3[0]+" | "+t.t3[1]+"| "+t.t3[2]);
               System.out.println(cm.car4[0]+"|"+cm.car4[1]+"|"+cm.car4[2]+" | "+d.d4[0]+" |"+d.d4[1]+" |"+t.t4[0]+" | "+t.t4[1]+"| "+t.t4[2]);
               System.out.println(cm.car5[0]+" |"+cm.car5[1]+" |"+cm.car5[2]+" | "+d.d5[0]+" |"+d.d5[1]+" |"+t.t5[0]+"| "+t.t5[1]+"| "+t.t5[2]);              
               System.out.println("====================================================================");  
               break;
               case 5:
               System.exit(0);
               break;
               default:
               break;              
           }
       }
   }
}
class Carsmodel extends Cars
{
   String car1[]={"Ferrari","PORCHE","2011"};
   String car2[]={"Suzuki","SX4","2015"};
   String car3[]={"Mahindra","XYLO","2014"};
   String car4[]={"Mahindra","SCORPIO","2014"};
   String car5[]={"Skoda","RAPID","2015"};

}
class Dealer extends Cars
{
   String d1[]={"USA","+10001"};
   String d2[]={"Chennai","600600"};
   String d3[]={"Chennai","600601"};
   String d4[]={"Hyderabad","535000"};
   String d5[]={"Banglore","453111"};
}
class Type extends Cars
{
   String t1[]={"Red","4 Seater","All"};
   String t2[]={"Silver","5 Seater","All"};
   String t3[]={"Blue","8 Seater","All"};
   String t4[]={"White","8 Seater","All"};
   String t5[]={"Purple","5 Seater","All"};
}

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