• March 30th, 2011, 01:40 AM
pagalas07
Our teacher was always on leave and so she doesn't teach us about java programming. She always leave a problem to us without even knowing how to deal with that kind of problem and what codes should we use for it.

Here's the problem I hope you can help me. :(

1. Write a program that would store the square of the first 7 even numbers (2, 4, 6, 8, 10, 12, 14) into array with 7 elements. Program must then display all the array elements together with its sum.

2. Barney has 10 children. Write a program that would enter the age of his 10 children into an array with 10 elements. The age of his youngest child will go into the 1st element and so on with the age of the oldest child going into the last element. Program must then display the following:

a. age of all his children form the oldest to the youngest.
b. The average age
c. Count of all teenagers (teenagers are from age 13 – 19, inclusive)
• March 30th, 2011, 07:33 AM
KevinWorkman
That's not how this works. We are not a homework service. What have you done so far? Where are you stuck? Please read the link in my signature on asking smart questions, then post an SSCCE with a specific question.

You violated just about every unwritten rule about posting. Your post title is vague and will be ignored by most users. Complaining about your educator makes you seem lazy- many people here are self-taught, without the aid of a classroom, an educator, classmates, etc. And simply dumping your homework questions here pretty much guarantees that nobody is going to help you.

But like I said, post an SSCCE demonstrating what you tried and where you're stuck, ask a specific question, and we'll go from there.
• March 30th, 2011, 08:41 AM
pagalas07
```import java.util.Scanner; import java.util.Arrays;   public class arrays{ public static void main(String args[]){   int sum=0; int average; int age = 10;   int []number = new int[age];   Scanner input = new Scanner(System.in);     for(int index=0; index<age; index++) { System.out.print("Enter Barney's children's age: "); number[index] = input.nextInt(); } Arrays.sort(number); System.out.println("Ages of Barney's children are sorted in ascending order"+"\n"+ Arrays.toString(number)); System.out.println();   for(int i=0; i<= 9; i++) sum = sum + number[i]; System.out.print("the average age is " + sum/10+"\n");     } }```