Machines do not mind doing the same thing over and over again; they never get bored. They are also capable of handling massive amounts of data in an impeccably organized manner. One of your challenges...

1 answer below »

Machines do not mind doing the same thing over and over again; they never get bored. They are also capable of handling massive amounts of data in an impeccably organized manner. One of your challenges as a programmer is to communicate, through code, in an efficient way that plays to the computer’s strengths.


Consider, for example, having to write a program to manage personnel records for all of the people working for your company. You certainly would not want to have to write a program with a unique variable for each unique person in the company. Every time a new employee was hired, someone would have to modify the program to add a new variable for that employee. Every time an employee left the company, someone would have to modify the program to remove that employee’s variable and data from the program. Clearly, this would be a very tedious way to automate personnel records. Instead, you need a way to manage that collection of personnel information in a more organized manner. In fact, you need a way of representing the collection of individual employees as just that, a single variable that provides access to all of the employees. Then, you can use loops to process the employee data. Fortunately, Java provides the concept of an array (and other similar collections, such as the ArrayList) to manage collections of similar objects.


It takes time to truly grasp how powerful object-oriented programming can be and how you can harness its "objects-first" focus to make your own programs concise and elegant. Unfortunately, some programmers do not invest that time. They rely on brute force—repetitive methods resulting in long programs that are, by nature, hard to review and debug.


Find an open source JAVA repositories online. Find a program that (A) uses at least one loop and a list effectively or (B) could use a loop and a list to improve the program.


Summarizes your findings. The assignment should:



  • Include a copy of the code that either (A) exemplifies concise, generalized code or (B) presents the perfect opportunity to apply loops, arrays, and lists to reduce the length of the program using a more elegant solution. Do not undertake a lengthy program; limit your code to approximately 20 lines.

  • If the code is an exemplar of good coding, explain what leads you to that conclusion. Be specific.

  • If the code needs improvement, include a rewritten version of the code, in which you applyoneof the methods described above to improve the program. Explain how your solution better embraces a computer’s strengths as a tool that can perform calculations quickly, perform repetitive tasks, and/or manage data effectively.

  • Add or revise comments in the code to accurately describe the function of the loop and list.

  • Be 350-500 words


Do not include the entire source code of the program you choose. Select just the portion with the necessary information, such as variable declarations and methods called from outside the class or method.

Answered 1 days AfterNov 22, 2021

Answer To: Machines do not mind doing the same thing over and over again; they never get bored. They are also...

Neha answered on Nov 23 2021
115 Votes
Code:
//Include library
import java.util.ArrayList;
//Define a class lArrayList
public class lArrayL
ist
{
     //Main
     public static void main(String[] args)
     {
          //Define an array list with inital capacity
ArrayList larrlist = new ArrayList(5);
          //Add elements in list
          larrlist.add(10);
          larrlist.add(21);
          larrlist.add(31);
          larrlist.add(41);
          // adding element 25 at third position
          larrlist.add(2,25);
          //Display all elements in list
          for (Integer number : larrlist)
          {
              System.out.println("Number = " + number);
          }
     }
}
Explanation
The given code can be a good example of utilizing list and loops. This example includes an array list. Java allow us to import the array list and it is the part of util library in Java. It has a class at the main method. It is the public static void main search the whole code is written. It defines the array list which is of...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here