Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Java only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
Java
help with nested loops
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
karthikshivram
New Member
Join Date:
Feb 2007
Posts:
1
#1
help with nested loops
Feb 7 '07, 02:38 PM
im new to java i need help with a code for the following output
+++++
++++
+++
++
+
horace1
Recognized Expert
Top Contributor
Join Date:
Nov 2006
Posts:
1510
#2
Feb 7 '07, 03:05 PM
Originally posted by
karthikshivram
im new to java i need help with a code for the following output
+++++
++++
+++
++
+
initially write a program to print
+
then add a loop to print
++++
then see if you can figure out how to make it do
++++
+++
++
+
Comment
Post
Cancel
JavaStudent07
New Member
Join Date:
Jan 2007
Posts:
64
#3
Feb 7 '07, 04:05 PM
You probably could set "+" equal to a string and to a concatonation, there are a lot of ways to run that program.
Comment
Post
Cancel
abctech
New Member
Join Date:
Dec 2006
Posts:
157
#4
Feb 7 '07, 04:56 PM
Originally posted by
karthikshivram
im new to java i need help with a code for the following output
+++++
++++
+++
++
+
Try writing the code yourself first..its really easy and then post it if you have any errors or aren't getting the correct output!
Take a look at
this
thread, it is not the same as your query but it may give you some idea on how to use loops to get the desired output pattern!
Comment
Post
Cancel
bala1980
New Member
Join Date:
Feb 2007
Posts:
3
#5
Feb 8 '07, 10:02 AM
Originally posted by
karthikshivram
im new to java i need help with a code for the following output
+++++
++++
+++
++
+
Try the following program
public class SamplePgm1 {
/**
* @param args
*/
public static void main(String[] args) {
for(int i = 5; i > 0; i--) {
for(int j = 0; j < i; j++) {
System.out.prin t("+");
}
System.out.prin tln("");
}
}
}
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment