0% found this document useful (0 votes)
14 views

Java Basics Project-Overview

This document contains source code for a Java application that performs several math calculations: 1) Methods to calculate harmonic series and factorials. 2) A bubble sort method to sort arrays. 3) A method to convert decimals to binary. 4) The application uses JTextFields for input/output and action listeners to trigger the calculations.

Uploaded by

Raveen Vasudeva
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Java Basics Project-Overview

This document contains source code for a Java application that performs several math calculations: 1) Methods to calculate harmonic series and factorials. 2) A bubble sort method to sort arrays. 3) A method to convert decimals to binary. 4) The application uses JTextFields for input/output and action listeners to trigger the calculations.

Uploaded by

Raveen Vasudeva
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Zip file containing source code Zip file containing executable jar file

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); }

You might also like