Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
john paschal
Greenhorn
+ Follow
1
Posts
0
Threads
0
Cows
since Sep 12, 2012
Merit badge:
grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
Ranch Hand Scavenger Hunt
Number Posts (1/100)
Number Threads Started (0/100)
Number Cows Received (0/5)
Number Likes Received (0/10)
Number Likes Granted (0/20)
Set bumper stickers in profile (0/3)
Report a post to the moderators (0/1)
Edit a wiki page (0/1)
Create a post with an image (0/2)
Greenhorn Scavenger Hunt
First Post
Number Posts (1/10)
Number Threads Started (0/10)
Number Likes Received (0/3)
Number Likes Granted (0/3)
Set bumper stickers in profile (0/1)
Set signature in profile
Search for a post/thread (0/3)
Set a watch on a thread
Save thread as a bookmark
Create a post with an image (0/1)
Recent posts by john paschal
Problem with spacing
here is the code using Scanner to obtain the number of segments and height from the user. copy and paste messed up my indenting but you get the idea
import java.util.*; public class Finally { public static void main ( String[] args ) { Scanner console = new Scanner(System.in); System.out.print("Enter the number of Segments: "); int segments = console.nextInt(); System.out.print("Enter the Height of each segment: "); int height = console.nextInt(); drawTrees(segments, height); } public static void drawTrees(int segments, int height) { for (int segs = 1; segs <= segments; segs++) { for (int line = 1; line <= height; line++) { for (int spaces = 0; spaces < ((segments - segs) + (height - line)); spaces++) { System.out.print(" "); } for (int dots = 0; dots < ((2 * line - 1) + 2*(segs - 1)); dots++) { System.out.print("*"); } System.out.println(); } } } }
show more
11 years ago
Beginning Java