I just started learning java and encounter problem in writing a program that read in the value of height of a triangle. For example
1 AA
232 BBAA
34543 AABBAA
4567654 BBAABBAA

Anyone plz kindly help me to write this program using loop. I only know how to print out the homogenous pyramid (ie single character). My main problem is how to switch around the number and letter in each line(hope u know what i mean from my example)
Thank you

...1
..232
.34543
4567654

...aa
..bbaa
.aabbaa

the example shud look like this. ignore the dots.

One more thing, does anyone know where is the best place to learn java? I mean with all the examples that i can practise on. Are there any tips from the experts on how to learn java effectively?

Well it should be the way you format the output string, so someone enters a 4 and it prints out a triangle with a height of 4, so for the top you would print out System.out.print 3 times (n-1) (which n = the input value) then print the 1, then as you print the next line of the pyrimad it would be ((n-1)-1) or n-2, with the same thing.
Please let me know if you need clarification on that.

As for a good resource for learning Java I would get Sams Teach Yourself Java in 21 Days.
And if you want to learn effectively I would suggest practice, don't just look at examples and reproduce them, try them first. Look at common problems (math ones are good) and try to solve those. Programming takes practice. A lot of people just know how to piecemeal a program ("textbook it"), which isn't the way to go.
Hopes this helps.

Member Avatar for iamthwee
...1
..232
.34543
4567654

...aa
..bbaa
.aabbaa

the example shud look like this. ignore the dots.

First of all, try writing a program to print just a triangle made of one single character where the user specifies a height, hint use two nested for loops.

x
     x x
   x x x
  x x x x

Once you've got your head around that, try and change it to meet the criteria above.

can u give me a copy of the pyramid program?pls....asap...tnx

Member Avatar for iamthwee

Sorry we don't do homework requests.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.