All pastes #536231 Raw Edit

Unnamed

public java v1 · immutable
·published 2007-06-04 09:47 UTC
rendered paste body
/* * Problem 2: Write a program that accepts two  * numbers from the command line and prints them out. * Then use a for loop to print the next 13 numbers in * the sequence where each number is the sum of the * previous two. For example: */public class prob2 {		int number_one = 0;	int number_two = 0; 	int seq_count = 0;	StringBuffer output = new StringBuffer("Sequence > \n");		public prob2(int number_one, int number_two) {		this.number_one = number_one;		this.number_two = number_two;	}		public void fibonacci() {			int old1 = this.number_one;			int old2 = this.number_two;						output.append(old1 + " "+ old2);						for(int i = 0; i < 13; i++) {				int answer = old1 + old2;				output.append(" "+answer);				old1 = old2;				old2 = answer;			}			System.out.println(output.toString());	}		public void go() {		fibonacci();	}		public static void main(String[] args) {				if(args.length < 2 || args.length > 2) {			System.out.println("Problem, you need insert two numbers");			System.exit(-1);		}		int argument_1 = Integer.parseInt(args[0]);		int argument_2 = Integer.parseInt(args[1]);		prob2 program = new prob2(argument_1, argument_2);		program.go();	}}