Answer to Question #3479 in Java | JSP | JSF for Y mukundareddy

Question #3479
(2) Write a program to store 10 elements through user input and sum the array of elements in to a word
1
Expert's answer
2011-08-07T07:18:34-0400
import java.io.*;

public class Task9
{
public static void main(String[] args) throws IOException
{
& // Preparing the stream
& BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));

& // reading the elements inputed by user
& String[] elements = new String[10];
& for (int i = 0; i < 10; i++)
& {
& System.out.print("Enter the element (string of the symbols): ");
& elements[i] = bReader.readLine();
& }

& // Summing the elements into a word:
& String word = new String();
& for (int i = 0; i < 10; i++)
& word += elements[i];
& System.out.print("\n\nThe sum of the array elements:\n" + word);
}
}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS