Java Basics Project-Overview
Java Basics Project-Overview
Math:
JTextField In 1-3
JTextField Out 1-3 Math calculations for: Harmonics Factorial Bubble Sort Convert Decimal to Binary
Harmonics: Methods for (int i = 1; i <= input; i++) { result += (1/(double) i); Action Listener: if (event.getSource()==input){ s = input.getText(); q = Integer.parseInt(s); r = findHarmonic(q); s = String.valueOf(r);
Factorial: Methods for (int i = 1; i <= input; i++) { result *= ((double)i); } Action Listener: if (event.getSource()==input){ s = input.getText(); q = Integer.parseInt(s); r = findFactorial(q); s = String.valueOf(r);
Bubble Sort: Methods for (int pass=1; pass<n; pass++){ for (int i=0; i<n-pass; i++){ if (a[i]>a[i+1]){ temp= a[i]; a[i]=a[i+1]; a[i+1] = temp; } } } Action Listener: s=Input.getText(); p.parseIn(s); p.convertInt(p.values); b.bubbleSort(p.int_values); out= p.convertInt_String(p.int_values); Output.setText(out);
Convert Decimal to Bonary: Methods while(num > 0) { rem = num % 10; num = num / 10; if(rem != 0 && rem != 1)// checks to see if input is binary { JOptionPane.showMessageDialog( null,"This is not a binary number. / n Please Try again"); } } int i= Integer.parseInt(str,2); String s= "" +i; Action Listener: txt2.setText(IntToBin(txt1.getText( )));
text.setText(s); }
text.setText(s); }