Exercise 1:  Visit the US News & World Report Best Electric Cars of 2021 (Links to an external site.) Website.   Create a new IntelliJ project called ElectricCarsList and add an empty public static void main method.  a.  Create and ArrayList and create a method to populate your String array by adding the  Model Names to an ArrayList (ArrayList of type String in order of ratings.  Create a method to print your results.  Call your methods from main to populate and print your results.   b.  Now let's add more information to make your list more interesting by following the instructions below to  print out your revised list:      Step 1:  Add an internal class to your ElectricalCars class something like the following;   public class ElectricCarList { ArrayList carModels = new ArrayList<>(); ArrayList carList = new ArrayList<>(); class ElectricCar { String modelName; double mfgPrice; int maxRange; double usNewsRating; // 1.0-10.0 int rank; }}  Step 2:  From inside your Electric Car class code in the IntelliJ editor,  right-mouse-click in the IntelliJ editor and  select the Generate menu item (or press Alt-Insert).  Generate getters for all attributes.  Right-mouse-click and select Generate again and create a Constructor.  Call Generate again and create a toString method.   Your ElectricCar class should now have getters for all attributes, a toString()  method that you can call to list the  names and values of all the attributes, and a Constructor for populating the class object.  Step 3:  Add a method to  ElectricCarList populate your ArrayList. The first line of your method should look something like:   public void addCars() { carList.add(new ElectricCar("2020 Tesla Model S", 74990, 402, 9.0,1)); // You add code to add the other cars to your list } Step 4:   Add a printList() method to your ElectricCarList,  then add something like the following to your main method;   public static void main(String[] args) { // Create a car list, populate, and print it out ElectricCarList cars = new ElectricCarList(); cars.addCars(); cars.printList(); } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Exercise 1: 

Visit the US News & World Report Best Electric Cars of 2021 (Links to an external site.) Website.  

Create a new IntelliJ project called ElectricCarsList and add an empty public static void main method. 

a.  Create and ArrayList<String> and create a method to populate your String array by adding the  Model Names to an ArrayList<String> (ArrayList of type String in order of ratings.  Create a method to print your results.  Call your methods from main to populate and print your results.  

b.  Now let's add more information to make your list more interesting by following the instructions below to  print out your revised list:     

Step 1:  Add an internal class to your ElectricalCars class something like the following;  



public class ElectricCarList {

ArrayList<String> carModels = new ArrayList<>();
ArrayList<ElectricCar> carList = new ArrayList<>();

class ElectricCar {
String modelName;
double mfgPrice;
int maxRange;
double usNewsRating; // 1.0-10.0
int rank;
}}

 Step 2:  From inside your Electric Car class code in the IntelliJ editor,  right-mouse-click in the IntelliJ editor and  select the Generate menu item (or press Alt-Insert).  Generate getters for all attributes.  Right-mouse-click and select Generate again and create a Constructor.  Call Generate again and create a toString method.   Your ElectricCar class should now have getters for all attributes, a toString()  method that you can call to list the  names and values of all the attributes, and a Constructor for populating the class object. 

Step 3:  Add a method to  ElectricCarList populate your ArrayList<ElectricCar>. The first line of your method should look something like:  

public void addCars() {
carList.add(new ElectricCar("2020 Tesla Model S", 74990, 402, 9.0,1));
// You add code to add the other cars to your list
}
Step 4:   Add a printList() method to your ElectricCarList,  then add something like the following to your main method;  
public static void main(String[] args) {
// Create a car list, populate, and print it out
ElectricCarList cars = new ElectricCarList();
cars.addCars();
cars.printList();

}
}
Expert Solution
Step 1

Actually, given information:

Visit the US News & World Report Best Electric Cars of 2021 (Links to an external site.) Website.  

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education