Using Java code and ARRAYS, please write a program that takes in the names of four individuals and prints out all the names. The number of names (4) is predetermined.
import java.util.Scanner; public class Names4 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String names[] = new String[4]; for(int i = 0;i<4;i++){ System.out.print("Enter name: "); names[i] = scan.nextLine(); } System.out.println("\nNames are"); for(int i = 0;i<4;i++){ System.out.println(names[i]); } } }
Get Answers For Free
Most questions answered within 1 hours.