1- Write code that creates an array of Strings with the name of \"firstNames\".
ID: 3640681 • Letter: 1
Question
1-Write code that creates an array of Strings with the name of "firstNames".
Fill the array with the names:
"George", "Fred", "Sam", "Mary", "Sarah",
"Bella", "Joy", "Rita", "Marta", "Sue", "Nancy"
Print the values of the firstNames array backwards.
___________________________________________________________________________
2-
Write code for the following 2 methods:
void fillBoolean(boolean[] arr)
and
void printBoolean(boolean[] arr)
fillBoolean will fill the arr array passed in with alternating
true false values. For example:
arr[0] = true;
arr[1] = false;
arr[2] = true;
... etc.
The printBoolean routine will print out the contents of
the array arr passed in. Create a main routine to
test out your fillBoolean and printBoolean methods.
____________________________________________________________________________
3-
Write code for the following 2 methods:
int[] createIntegers(int size_of_array)
and
void printIntegers(int[] arr)
createIntegers will create an array the size specified in "size_of_array".
createIntegers will also fill the created array with values
that increase by 100.
For example:
arr[0] = 0;
arr[1] = 100;
arr[2] = 200;
... etc.
The printInteger routine will print out the contents of
the array arr passed in. Create a main routine to
test out your createInteger and printInteger methods.
_____________________________________________________________________________
4-
Write code that creates an array of Dates with the name of "dateArr".
The array should have 4 entries and the entries should be filled with
Date classes representing the dates:
May 16, 1984
November 14, 1978
September 21, 1980
July 3, 1987
Print the values of the dateArr array backwards.
Your Date classes can be printed using the toString() method in the Date class.
public String toString( )
{
return (month + " " + day + ", " + year);
}
Explanation / Answer
ArrayUtil.java package util; public class ArrayUtil { public void dispReverse(String[] firstNameArray) { for (int i = firstNameArray.length - 1; i >= 0; i--) { System.out.println(firstNameArray[i]); } } public void fillBoolean(boolean[] arr){ for (int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.