Page 8 of 9 FirstFirst ... 56789 LastLast
Results 71 to 80 of 90
  1. #71

    Quote Originally Posted by FrozenBoi View Post
    up..up..up..... gmay nlng..
    Ngano wala na man lain mo answer?

  2. #72
    Abi nako ug dugay ko mo answer naa na lain mo answer

    Mura mas daghan cguro ang C#, VB & .NET programmers


    Code:
    /*
    24. Write a Java class called AppearInOrder(), which defines a main() method that asks the user to enter two
     Strings subString and superString, and displays whether or not all the characters of subString appear in
     order in superString. You MUST NOT use any of the 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 AppearInOrder {
    
        public static void main(String[] args) {
          BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    
    
            String superString = new String();
            String subString = new String();
    
            System.out.println("Please enter a super string: ");
    
            try {
                superString = input.readLine();
            } catch (IOException ex) {
                System.err.println(ex);
            }
    
            System.out.println("Please enter a sub string: ");
    
            try {
                subString = input.readLine();
            } catch (IOException ex) {
                System.err.println(ex);
            }
    
    
            
    
            int position = 0;
    
            boolean inOrder = true;
    
            for (int i = 0; i < subString.length(); i++) {
                for (int j = 0; j < superString.length(); j++) {
                    if (subString.charAt(i) == superString.charAt(j)) {
                        if (position>j) {
                            inOrder = false;
                        } else {
                            position = j;
                            break;
                        }
                    }
                }
    
            }
    
            if (inOrder) System.out.println("Character sequence is in order");
            else System.out.println("Character is NOT in order");
        }
    
    }
    Ug naa problema ang code, ikaw na bahala usab, similar pattern ra sila

  3. #73
    Quote Originally Posted by javapenguin View Post
    Ngano wala na man lain mo answer?
    master javaP .. murag g lisodan na cla sa n habilin.....

    pakyawa nlng na heheheh...

  4. #74
    Quote Originally Posted by FrozenBoi View Post
    master javaP .. murag g lisodan na cla sa n habilin.....

    pakyawa nlng na heheheh...
    Bali cguro, gi snab ra ni sa mga java experts kay dili challenging enough, hehehe

  5. #75
    Quote Originally Posted by javapenguin View Post
    Bali cguro, gi snab ra ni sa mga java experts kay dili challenging enough, hehehe
    korek gyud bai... taga-an pod nato sila ug chance nga mo try ug solve sa remaining problems. anyway 6/25 nalang man nang nabilin.

  6. #76
    Quote Originally Posted by bishop__ View Post
    anyway 6/25 nalang man nang nabilin.

    4 nlng jud nhabilin....

    11-14-17-23....

  7. #77
    pahalipay

    Code:
    /**
     * 17. Write a Java class called MaxConsecutiveOccurrences, which defines a 
     * main() method that asks the user to enter a String s and a character c, 
     * and displays the position in s at which the longest series of consecutive 
     * occurrences of c occurs. If there is a tie between two positions, you 
     * should return the lowest position. You MUST NOT use any of the methods 
     * defined in the String class other than charAt() and length().
     *
     * @author bishop__
     */
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    
    public class MaxConsecutiveOccurrences {
    
        public static void main(String[] args) {
            BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
            
            String s = new String();
            String ch = new String();
            char c = ' ';
            
            System.out.println("Please enter a string: ");
            
            try {
                s = input.readLine();
            } catch (IOException ex) {
                System.err.println(ex);
            }
            
            boolean invalid = true;
            
            while (invalid) {
                invalid = false;
                System.out.println(" ");
                System.out.println("Please enter a character: ");
                
                try {
                    ch = input.readLine();
                } catch (IOException ex) {
                    System.err.println(ex);
                    invalid = true;
                }
                if (ch.length() != 1) invalid = true;
            }
            
            c = ch.charAt(0);
    
            int found_at = -1;
            int most_occur = -1;
            int curr_occur_count = 0;
            int prev_occur_count = 0;
    
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) { // oi! nakit-an nako ang akong gi at-ngan! 
                    curr_occur_count++; // atong ihapon ug pila kabuok... plus 1 ta
                    if (curr_occur_count == 1) found_at = i; // timan-an nato asa nato ug asa nga location unang nakita   
                    if (curr_occur_count > prev_occur_count) { // tan-awon ug kinsay labaw nila, ang bago nga ihap? or ang daan nga ihap?
                        most_occur = found_at; // ah, milabaw ang bag-ong ihap, mao ni ang location sa may pinakadaghan nga nag sunod nga occurence sa letra nga atong gi at-ngan
                        prev_occur_count = curr_occur_count; // ilisan nato ang daan natong ihap sa bag-o nato nga ihap
                    } 
                } else if (curr_occur_count > 0) { // walay nakit-an, ibalik nato ang atong ihap to 0
                    curr_occur_count = 0;  
                }
            }
            
            if (most_occur != -1) {
                System.out.println("Max consecutive occurrence of \"" + ch + "\" is at " + most_occur);
            } else {
                System.out.println("Character \"" + ch + "\" not found in string!");
            }
        }
    }

  8. #78
    An example of a Discrete Mathematics problem.
    usba lang ang message kun salikwaot basahon.

    Code:
    /**
     * 23. Write a Java class called SubSet, which defines a main() method that 
     * asks the user to enter two Strings superString and subString, and displays 
     * whether or not all the characters of subString occur anywhere in 
     * superString. You MUST NOT use any of the methods defined in the String 
     * class other than charAt() and length().
     *
     * @author bishop__
     */
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    
    public class SubSet {
    
        public static void main(String[] args) {
            BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
            
            String superString = new String();
            String subString = new String();
            
            System.out.println("Please enter a Super string: ");
            
            try {
                superString = input.readLine();
            } catch (IOException ex) {
                System.err.println(ex);
            }
            
            System.out.println("\nPlease enter a Sub string: ");
            
            try {
                subString = input.readLine();
            } catch (IOException ex) {
                System.err.println(ex);
            }
         
            int count = 0;
    
            for (int x = 0; x < subString.length(); x++) {
                for (int y = 0; y < superString.length(); y++) {
                    if (subString.charAt(x) == superString.charAt(y)) {
                        count++;
                        break;
                    }
                }
            }
                    
            if (count == subString.length()) {
                System.out.println("All characters inside \"" + subString + "\" can be FOUND inside \"" + superString + "\"");
            } else {
                System.out.println("NOT all characters inside \"" + subString + "\" can be FOUND inside \"" + superString + "\"");
            }
        }
    
    }

  9. #79

  10. #80
    wew! tnx Bishop.....

    2 nlng jud.... 11 & 14

    mga masters of java man mu oi..

  11.    Advertisement

Page 8 of 9 FirstFirst ... 56789 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