Page 6 of 9 FirstFirst ... 345678 ... LastLast
Results 51 to 60 of 90
  1. #51

    go go go go javapenguin hehe maypa dre ko storya saona patabang dah... dako2 tana ko grade sa JAVA..... hahaha

  2. #52
    Quote Originally Posted by josephG View Post
    @bishop and javapenguin
    Grabiha sd nnu mo hatag answer e hungit mn sd nnu tanan..hehe
    Lingaw2x lang man ni ako josephG. hehehe.... pero tama na to ako gihatag, halos parepareho ra man ang solutions sa tanang problems from 1-25. maka kuha na sila ideas ato.

  3. #53
    most of the answers of these problems can be done, in the console, but ang lingaw ani nga answer no, kanang mo.gamit Swing components, ug kanang naa GUI bah, kay magkabuang lagi na ug tubag sa ilang maestro! Hahahahahaha

    Bantay mooooo! Explain jud mo anaaaa!!! Ahahahahaha!

  4. #54
    Quote Originally Posted by ChaosOrb View Post
    most of the answers of these problems can be done, in the console, but ang lingaw ani nga answer no, kanang mo.gamit Swing components, ug kanang naa GUI bah, kay magkabuang lagi na ug tubag sa ilang maestro! Hahahahahaha

    Bantay mooooo! Explain jud mo anaaaa!!! Ahahahahaha!

    hahahaha ok ra ui wla btaw n oral defense,,,,, mao sabot nmu sa maestro... pang add rni sa points

  5. #55
    idola ning javapenguin

    ai kalimti ug earese ngan sa author inig pass ninyo

  6. #56
    While I'm waiting for netbeans 6.5 download and installation, I'll make problem #2, this is an interesting example of recursion (a method calling itself)

    Code:
    /*
    * 2. Write a Java class called Fibonacci which defines a main() method that asks the user to enter a positive
    * integer n, and computes the nth Fibonacci number. The nth Fibonacci number is defined by this formula:
    * o 0th Fibonacci number: 0
    * o 1st Fibonnaci number: 1
    * o nth Fibonacci number (for n >= 2): (n-1)th Fibonacci number + (n-2)th Fibonacci number
     */
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    
    /**
     *
     * @author javapenguin
     */
    public class Fibonacci {
    
        public static void main(String[] args) {
            BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
            
            boolean invalid = true;
            
            String number = new String();
            
            while (invalid) {
                invalid = false;
                System.out.println("Please enter a positive integer number: ");
                try {
                    number = input.readLine();
                } catch (IOException ex) {
                    System.err.println(ex);
                    invalid = true;
                }
                int trynum = 0;
                try {
                    trynum = Integer.parseInt(number);
                } catch (NumberFormatException nfe) {
                    invalid = true;
                }
                if (trynum < 0) invalid = true;
                number = String.valueOf(trynum);
            }
            
            System.out.println("Fibonacci of "+number+" is "+fibonacci(Integer.parseInt(number)));
        }
    
        static int fibonacci(int n) {
            int fn = 0;
            if (n == 0) fn = 0; //can be omitted
            if (n == 1) fn = 1;
            if (n >= 2) fn = fibonacci(n-1)+fibonacci(n-2);
            return fn;
        }
    
    }
    This reminds me of the subject numerical methods a long time ago

  7. #57
    good work on recursion javapenquin, here is my take on the iterative side!

    Code:
     a = 0;
     b = 1;
    
     for(x = 1; x <= num; x++) {
      a = a + b;
      b = a - b;
      
     }
    System.out.println("Fibonacci Number of "+ num + " is: "+b);
    Note: if you want to display the Fibonacci Number Sequence, put the console output inside the loop.

  8. #58
    Quote Originally Posted by ChaosOrb View Post
    good work on recursion javapenquin, here is my take on the iterative side!

    Code:
     a = 0;
     b = 1;
    
     for(x = 1; x <= num; x++) {
      a = a + b;
      b = a - b;
      
     }
    System.out.println("Fibonacci Number of "+ num + " is: "+b);
    Note: if you want to display the Fibonacci Number Sequence, put the console output inside the loop.
    I like the simplicity of your approach, I may be wrong but I think you need to put +1 in num of your for loop

    Code:
     a = 0;
     b = 1;
    
     for(x = 1; x <= num+1; x++) {
      a = a + b;
      b = a - b;
      
     }
    System.out.println("Fibonacci Number of "+ num + " is: "+b);
    Fibonacci number - Wikipedia, the free encyclopedia

  9. #59
    Update 1.1

    ang wla pa n solve ky numbers 11-14-17-20-22-23-24

    ^_^

  10. #60
    Wala na lain nga java programmer ganahan mo answer? hehehe

    Code:
    /*
     20. Write a Java class called KillWhiteSpace, which defines a main() method that asks the user to enter a
     String s, and displays a new String consisting of all the characters in s, but with the leading and trailing
     white space removed. In addition, every sequence of spaces within the String is reduced to one space only.
     You MUST NOT use any methods defined in the String class other than charAt() and length()./*
     */
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    
    /**
     *
     * @author javapenguin
     */
    public class KillWhiteSpace {
    
        public static void main(String[] args) {
    
            BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    
            String s = new String();
    
            System.out.println("Please enter a string: ");
    
            try {
                s = input.readLine();
            } catch (IOException ex) {
                System.err.println(ex);
            }
    
            s = s+" ";
    
            String ns =  new String();
            for (int i = 0; i < s.length()-1; i++) {
                if (!(s.charAt(i) == ' ' && s.charAt(i+1) == ' ')) {
                    ns =  ns + s.charAt(i);
                }
                
            }
    
            String nns = new String();
    
            if (ns.length()>1 & ns.charAt(0) == ' ')
            for (int i = 1; i < ns.length(); i++) {
                nns = nns+ns.charAt(i);
            } else {
                nns = ns;
            }
    
            System.out.println("New string > "+nns);
            
        }
    
    }

  11.    Advertisement

Page 6 of 9 FirstFirst ... 345678 ... LastLast

Similar Threads

 
  1. Need Help in java. AGAIN! =)
    By jairoh_ in forum Programming
    Replies: 11
    Last Post: 02-29-2012, 08:13 AM
  2. Help in java. Arrays
    By jairoh_ in forum Programming
    Replies: 25
    Last Post: 02-03-2012, 07:48 PM
  3. Help in java
    By jairoh_ in forum Programming
    Replies: 12
    Last Post: 01-11-2012, 10:22 AM
  4. NEED HELP in JAVA EXCELAPI
    By rastaman81 in forum Programming
    Replies: 1
    Last Post: 05-11-2009, 09:17 PM
  5. need help in java programming: creating a folder
    By rastaman81 in forum Programming
    Replies: 4
    Last Post: 03-11-2009, 08:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top