Page 5 of 9 FirstFirst ... 2345678 ... LastLast
Results 41 to 50 of 90
  1. #41

    Quote Originally Posted by FrozenBoi View Post
    Waaaa!! mga master Java man di mu..

    Update nko kng unsa wla pa n solve....

    11-14-17-18-19-20-22-23-24.......

    sa mga nka solve salamat jud kaayo..
    c lord nai bhala ninyo... kbw nmu kng kinsa mu...
    ayay! gamay nalang man diay.... i suggest nga kaw nalang tingali mo solve ana total layo pa btaw deadline pod. para maka tuon pod ka bai.

    java is a fun language to learn.

  2. #42
    Quote Originally Posted by FrozenBoi View Post
    Waaaa!! mga master Java man di mu..

    Update nko kng unsa wla pa n solve....

    11-14-17-18-19-20-22-23-24.......

    sa mga nka solve salamat jud kaayo..
    c lord nai bhala ninyo... kbw nmu kng kinsa mu...
    kuhaon nato nato ning tunga nga problem:
    Code:
    /*
     * 19.	Write a Java class called IsPalindrome, which defines a main() method 
     * that asks the user to enter a String s, and displays whether or not s is a 
     * palindrome. A palindrome is a String which reads the same forwards and 
     * backwards, such as "laval" or "stressed desserts".
     * 
     * Code taken from my previous solution of problem #21
     *
     * @author bishop__ 
     */
    
    import javax.swing.*;
    import java.text.*;
    class IsPalindrome {
    	public static void main( String[] args ) {
    		String s1, s2;
    		int result = 0, len, index1, index2;
    
    		s1 = JOptionPane.showInputDialog(null, "Enter a string:");
    		s2 = s1;
    		len = s1.length();
                    // improvement: string can be cut into half to speedup comparison
           		for (index1 = 0, index2 = len - 1; index1 < len; index1++, index2--) {
    			if (s1.charAt(index1) != s2.charAt(index2)) {
    				result = -1;
    			} 
    		}			
    		
    		if (result == 0) {
    			JOptionPane.showMessageDialog(null, "Palindrome !");  
    		} else {
    			JOptionPane.showMessageDialog(null, "Not Palindrome !");
    		}
    	}
    }

  3. #43
    solutions 19 and 21 can further be enhanced by adding break; after setting result = -1;

  4. #44
    Quote Originally Posted by bishop__ View Post
    solutions 19 and 21 can further be enhanced by adding break; after setting result = -1;
    further enhancement for #19
    s2 variable not necessary.
    for loop condition change to index1 < index2
    if condition change to s1.charAt(index1) != s1.charAt(index2)

  5. #45
    Quote Originally Posted by moz_k2 View Post
    further enhancement for #19
    s2 variable not necessary.
    for loop condition change to index1 < index2
    if condition change to s1.charAt(index1) != s1.charAt(index2)
    yay! seen it too... hehehe forgot to mention thanks

  6. #46
    @bishop and javapenguin
    Grabiha sd nnu mo hatag answer e hungit mn sd nnu tanan..hehe

  7. #47
    Quote Originally Posted by bishop__ View Post
    grabeha mo code javapenguin oi! with error trappings naman. hehehehe...

    ako kay basic lang basta mo solve lang sa problem. saon nga self study lang man ko ani sa java then wala pod mi nag gamit java sa work. hehehehe....
    You're really good bro, considering you don't use java in your work and you learned it by self studying, in my case I use it everyday.

  8. #48
    Quote Originally Posted by josephG View Post
    @bishop and javapenguin
    Grabiha sd nnu mo hatag answer e hungit mn sd nnu tanan..hehe
    Bahala na ma tuk-an ug mag suka suka hahaha

  9. #49
    Problem #18

    Code:
    /*
     * 18. Write a Java class called Reverse, which defines a main() method that asks the user to enter a String s, 
     * and displays a new String consisting of the characters in s in the reverse order. 
     * 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 Reverse {
    
        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);
            }
    
            char [] chr_array = new char[s.length()];
            
            int j = 0;
            
            for (int i = s.length()-1; i >= 0;i--) {
                chr_array[j] = s.charAt(i);
                j++;
            }
            
            //new string in reverse order
            String rs = new String(chr_array);
            
            System.out.println("The reverse is > "+rs);
        }
    
    }

  10. #50
    Quote Originally Posted by Eiso View Post
    CmpE pud diay ka naa mo java sauna??

    naa murag kami ang ng.una sa amo batch sa COMP.E nga ng JAVA usa ra nuon ka subject ng,kumbitay jud ako grado ato... hehehe

  11.    Advertisement

Page 5 of 9 FirstFirst ... 2345678 ... 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