510,681 views
40 votes
40 votes
Create a List with People's name you are thankful for. Create a While loop that goes thru the list and prints a thank you note to them.

plsss helpp mee
tell me the code

User Saurabh Bhola
by
3.1k points

1 Answer

22 votes
22 votes

Answer:

public static void main(String[] args) {

// List of the people

String[] myArray = {"John", "Jack", "Luke", "Ali", "Zara"};

// Saving the length of the array

int length = myArray.length;

// Used for checking the index of myArray and printing out each element

int counter = 0;

while (counter < length){

// Printing the note

System.out.println("Thank you, " + myArray[counter]);

counter++; // Moving to the next index

}

}

Step-by-step explanation:

The code is written in Java. If you need help with modifying it for another language, let me know!

User Zzevannn
by
2.6k points