Question

Using Java code and ARRAYS, please write a program that takes in the names of four...

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.

Homework Answers

Answer #1
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]);
        }
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please code in Java Write a recursive method that takes a string and return a string...
Please code in Java Write a recursive method that takes a string and return a string where every character appears twice. For example, if the string is “HELLO”, it will return “HHEELLOO”. Write a program to test it.
A. Write a Java program that asks the user to enter “bus” or “subway” or “walk”....
A. Write a Java program that asks the user to enter “bus” or “subway” or “walk”. If the user enters “bus” display “$1.00”. If they enter “subway” display “$1.50 and if they enter “walk” display “Free”. B. Write a java program that creates the following two arrays: String[] candidates = {“S Jones”,”Justin Fairfax”,”Clark Duncan”}; int[] votes = {7345,4324,3211}; Write the code that will search the votes array for the candidate with the largest number of votes and prints the name...
Using for loops: - write a Java program that adds numbers between 1 to 100 and...
Using for loops: - write a Java program that adds numbers between 1 to 100 and prints the result. - write a Java program that adds odd numbers between 1 to 100 and prints the result - write a Java program that averages even numbers between 5 to 30 and prints the result
Write a Python program using that takes a number as input and then prints if the...
Write a Python program using that takes a number as input and then prints if the number is even or odd. The program should use a function isEven that takes a number as a parameter and returns a logical value true if the number is even, false otherwise.
write a java code. Write a program using loops to compute the sum of the 30...
write a java code. Write a program using loops to compute the sum of the 30 terms of the series below. 91/(3 + 2 + 2) + 92/(4 - 4 + 5) + 93/(5 + 6 - 8) + 94/(6 - 8 + 11) + 95/(7 + 10 + 14) + 96/(8 - 12 - 17) + . . . . Output: Term Ratio Sum 1 13 13 2 18.4 31.4 etc etc
In Java. Write a program that reads-in a times table-number. The program, using this table-number will...
In Java. Write a program that reads-in a times table-number. The program, using this table-number will produce the following report (as shown). The first item in the report is a number with starting value 1. Second column is the word “ X ” (representing the times symbol). Third column is the table-number (itself). Following is an equal sign “ = “ (representing a result). Last column is the result of the operation for that line or row which is the...
Write Java program Lab51.java which takes in a string from the user, converts it to an...
Write Java program Lab51.java which takes in a string from the user, converts it to an array of characters (char[] word) and calls the method: public static int countVowels(char[]) which returns the number of vowels in word. (You have to write countVowels(char[]) ).
PLEASE USE IDLE PYTHON: Question (Arrays/Lists) A teacher uses 2   arrays (or Lists) to keep track...
PLEASE USE IDLE PYTHON: Question (Arrays/Lists) A teacher uses 2   arrays (or Lists) to keep track of his students. One is used to store student names and the other stores his grade (0-100). Write a program to create these two arrays (or lists) that are originally empty, and do the following using a menu: 1. Add a new student and his/her grade. 2. Print the name and grade of all current students, one student per line. 3. Display the number...
Write a program in JAVA that prints the bounds ( maximum and minimum values) for all...
Write a program in JAVA that prints the bounds ( maximum and minimum values) for all integer data types in Java.
C program- using visual studio code. Write a program that asks for an integer and then...
C program- using visual studio code. Write a program that asks for an integer and then prints all the alternative integers from (and including) that value up to (and including) a value larger by 20. (That is, if the input is 5, the output runs from 5 to 25.) Be sure to separate each output value by a space or tab
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT