Results 1 to 6 of 6
Thread: java problem
- 08-14-2009, 05:20 AM #1
Member
- Join Date
- Aug 2009
- Posts
- 1
- Rep Power
- 0
java problem
i need help for this problem...
"write a program that ask the user to enter the size of a triangle (1 to 50).then print the triangle by printing a series of lines consisting of asterisks.the first line will have 1 asterisk, the next two will have two and so on....with each line having one more asterisk than the previous line up to the number entered by the user.on the next line print one less asterisk and continue by decreasing the number of esterisk by 1 for each successive line until any one asterisk is printed."
hint: use nested loops, the outside loop controls the number of lines and the inside loops controls the number of asterisk to print on a line.
i hope, anyone will help me on this problem...pls....
-
What you've done is to post your entire assignment without showing what work you've done, and that is not how to get help here (or at any forum). For one, we have no idea what you're having trouble with, so we won't know how to advise you. For another, it suggests that you want someone to post a complete solution, thereby doing your homework for you, and I know that this was not your intent.
So please try to solve the problem first, and then post what you've done using code tags (see my signature), and then ask a specific question. Do this and you'll have many folks willing to help you.
Much luck!
- 08-14-2009, 04:16 PM #3
Here it is
int input; //input from user
//Nested Loops
int count=0;
for(int i=0;i<input;i++)
{
for(int j=0;j<i;j++)
{
System.out.print("*");
}
System.out.println();
count=i;
}
if(count>=input-1)
{
for(int k=count;k>=0;k--)
{
for(int j=0;j<=k;j++)
{
System.out.print("*");
}
System.out.println();
}
}
================================================== ========
If the input =10;the result will be ass following:
*
**
***
****
*****
******
*******
********
*********
********** // 10(*)'s
*********
********
*******
******
*****
****
***
**
*HosHos :cool:
hoss.2011@hotmail.com
- 08-14-2009, 07:32 PM #4
Read the faq about using code tags. It makes the code much easier to read. Here is a link:
Java Forums - BB Code List
- 08-14-2009, 09:39 PM #5
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
this is where you state what you actually need help with in your code...
- 08-15-2009, 05:09 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
Help, java problem
By Suriman in forum New To JavaReplies: 4Last Post: 03-09-2009, 04:26 PM -
problem with java nio
By andrei stoiculescu in forum NetworkingReplies: 3Last Post: 02-02-2009, 03:35 PM -
Java problem
By grend in forum New To JavaReplies: 5Last Post: 08-18-2008, 11:44 PM -
Problem in java
By saytri in forum New To JavaReplies: 6Last Post: 01-09-2008, 04:13 PM -
java SE 6 problem
By techlance in forum Java AppletsReplies: 1Last Post: 06-28-2007, 10:10 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks