(3) Write a program to store 5 of your friend’s names in an array.
import java.io.*;
public class Task10
{
public static void main(String[] args) throws IOException
{
& // Preparing the stream
& BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));
& // reading the names of the friends
& String[] friendNames = new String[5];
& System.out.println("Enter the names of 5 your friends");
& for (int i = 0; i < 5; i++)
& {
& System.out.print("Enter the name of friend " + (i + 1) + ": ");
& friendNames[i] = bReader.readLine();
& }
& // All names are stored in array
& System.out.print("\nNow the array 'friendNames' stores 5 of your friend’s names");
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
JavaJSPJSF