Results 1 to 19 of 19
Thread: Triangle program for beginner
 11142011, 09:37 PM #1Member
 Join Date
 Nov 2011
 Posts
 7
 Rep Power
 0
Triangle program for beginner
I have this problem. I just started taking a programmign class, and i'm so lost in this class...i need help with this problem
the program prints the following values
1
10
100
1000
10000
100000
1000000
10000000
100000000
1000000000
10000000000
100000000000
i have to write the algorithm for this and the program itself...if someone cane help me with this, i would be very thankful
 11142011, 10:00 PM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,655
 Blog Entries
 7
 Rep Power
 21
Re: Triangle program for beginner
Suppose we give an index number to each row as follows: the first row get index number 0, the next row gets number 1, etc. My question to you: how may zeros are there on a line with index number i?
kind regards,
Joscenosillicaphobia: the fear for an empty beer glass
 11142011, 10:01 PM #3Member
 Join Date
 Nov 2011
 Posts
 7
 Rep Power
 0
Re: Triangle program for beginner
no idea what it would be
 11142011, 10:10 PM #4
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,655
 Blog Entries
 7
 Rep Power
 21
Re: Triangle program for beginner
How many zeros are there on the first line (the index value of that line is 0)?
How many zeros are there on the second line (the index value of that line is 1)?
How many zeros are there on the third line (the index value of that line is 2)?
How many zeros are there on the fourth line (the index value of that line is 3)?
How many zeros are there .. ... ..... ... (the index value of that line is i)?
kind regards,
Joscenosillicaphobia: the fear for an empty beer glass
 11142011, 10:12 PM #5Member
 Join Date
 Nov 2011
 Posts
 7
 Rep Power
 0
Re: Triangle program for beginner
what is i?
i know how many zeros there are on each line
 11142011, 10:12 PM #6
Re: Triangle program for beginner
Do you have a piece of paper?
Write the characters for triangle just like you put in the first post. But leave some room on the side.
Now go down the side of the triangle you just wrote the characters for and place a row number/index next to each row. Start at the top with row 0, then 1 on the next row and so on until all the rows have numbers on them.
Now look at any row, and see how many zeros are on that row. Look at the row number. What is the relationship between the number of zeros on a row and the row number you wrote at the side of the row?
 11142011, 10:21 PM #7Member
 Join Date
 Nov 2011
 Posts
 7
 Rep Power
 0
 11142011, 10:40 PM #8
Re: Triangle program for beginner
Next you need to look at how to use a for loop and the print statement to print numbers all in a row.
 11142011, 10:43 PM #9Member
 Join Date
 Nov 2011
 Posts
 7
 Rep Power
 0
Re: Triangle program for beginner
for(int power = 0; power<13; power ++){
system.out.println(''+mathe.pow(10, power.)
}
 11142011, 10:55 PM #10
Re: Triangle program for beginner
What prints when you execute your code?
Do you get compiler errors with your code?
Why are you using the mathe.pow() method?
 11142011, 11:00 PM #11
 11142011, 11:03 PM #12Member
 Join Date
 Nov 2011
 Posts
 7
 Rep Power
 0
Re: Triangle program for beginner
doesnt work
 11142011, 11:05 PM #13
Re: Triangle program for beginner
Well that provides a ton of valuable information. Do you think that posting your latest code, error messages and a detailed description of what happens when you run your program would help us? Or should we just guess?
 11142011, 11:05 PM #14
Re: Triangle program for beginner
Please explain. Copy and paste the full text of the errors here.
Where did you get the code you posted in post#9?
Do you know how to read the API doc where the classes and methods are defined? Here's a link:
Java Platform SE 6
 11142011, 11:31 PM #15
Re: Triangle program for beginner
Just got this via PM:
Originally Posted by shawnx715Last edited by Norm; 11152011 at 12:38 PM.
 11142011, 11:38 PM #16
Re: Triangle program for beginner
Oh, so this is not one of those Triangle shape programs. It simply requires the powers of 10 to be output. Well that is even easier.
 11152011, 04:14 AM #17Member
 Join Date
 Nov 2011
 Posts
 7
 Rep Power
 0
Re: Triangle program for beginner
so how should i do this?

Re: Triangle program for beginner
 11152011, 12:40 PM #19
Similar Threads

Perimeter of a Triangle and Circle Program
By Zora in forum New To JavaReplies: 7Last Post: 10132011, 03:43 AM 
triangle program
By computerbum in forum New To JavaReplies: 8Last Post: 03022010, 04:55 AM 
Help with calculating triangle program
By ALH813 in forum New To JavaReplies: 5Last Post: 10192009, 05:08 AM 
Errors in Program (Right Triangle)
By SupaStudy in forum New To JavaReplies: 3Last Post: 03262009, 10:42 AM 
Triangle Sides program
By jamesov89 in forum New To JavaReplies: 6Last Post: 10062008, 03:36 AM
Bookmarks