Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Pascal's Triangle

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 03-05-2011, 11:20 PM PM User | #1 roher4 New Coder   Join Date: Jul 2010 Location: Canada Posts: 26 Thanks: 2 Thanked 0 Times in 0 Posts Pascal's Triangle I can't find the error's in this program. I had to create these methods and must use them. It's for my high school class and I've cut 19 errors to one. Code: ```import java.util.Scanner; public class Pascal{ public static void main(String[] args) { Scanner input= new Scanner(System.in); int rows = getRows(); while (rows != 0){ printTriangle(rows); rows = getRows(); } } public static long factorial(long n) { //A number that is leading up to the specified number for (int i=2,k=1; i<=n; i++){ k*=i; return k; } return 1; } public static int getRows(){ Scanner input= new Scanner(System.in); int rows=5; System.out.println("Please enter the number of rows:"); rows = input.nextInt(); return (rows); } public static long nCr(long n, long r){ return factorial(n)/factorial(r)*(factorial (n-r)); } public static void printTriangle(int r){ for (int i=1;i<=r;i++) { for(int j=1;j<=i; j++) { System.out.println(nCr(i-1,j-1)); } System.out.println(""); } } }```
 03-06-2011, 01:51 AM PM User | #2 barillitos New to the CF scene   Join Date: Mar 2011 Location: san antonio,TX Posts: 4 Thanks: 1 Thanked 0 Times in 0 Posts error what did the compiler spit out, what type of error?
03-06-2011, 04:38 PM   PM User | #3
roher4
New Coder

Join Date: Jul 2010
Posts: 26
Thanks: 2
Thanked 0 Times in 0 Posts
Quote:
 Originally Posted by barillitos what did the compiler spit out, what type of error?
Arithmetic exception..divide by zero?

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 02:02 PM.