Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Java Programming Problem: Pascal's Triangle

Mon Jul 20, 2009 3:05 am

Your job for this assignment: write a two class application that accepts a positive integer input (n) from the user, and then prints rows 0 through n to the console. The pattern above (ignoring the fancy blocking) should be the result when you input 6.

Your classes should be: PascalDriver, where main() resides; and PascalTri, where the real computational work is done. We have given PascalDriver to you. Finally, the code you submit for this assignment should be documented: every instance variable should have a comment that briefly describes its role, and before every method you should write a comment that describes what the method does.

Note:

1) This is a two class assignment. We've identified the classnames for you and given you the body of the driver class. Look carefully at the syntactic elements, such as braces, we've used to wrap the input box. You should paste the entirety of the PascalTri class in the box. Be sure that you don't paste the lines defining the class (E.g., public class PascalTri{...)

2) Unlike other OWL assignments, you only get three submission tries. Be sure to get the program running first before you submit.

import java.util.Scanner;

public class PascalDriver{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("Enter number of rows");
int rowCount = scan.nextInt();
PascalTri t = new PascalTri(rowCount);
t.displayRows();
}
}



Post a reply
  Related Posts  to : Java Programming Problem: Pascal's Triangle
 pascal triangle     -  
 convert pascal code to c ?     -  
 i want some help in java programming     -  
 Java Programming help please?     -  
 Programming a Defragger in Java     -  
 Programming Calendar Java     -  
 Triangle of stars (C++)     -  
 java tree problem     -  
 Draw Triangle using Lines     -  
 Drawing a triangle with colors     -