Results 1 to 4 of 4
  1. #1

    Default I need your help guys...


    /*design a parser that parse the given string and counts the number of characters that match the given data..using stack or queue ..*/

    ex.
    Given String : ABCDEFG
    INPUT STRING : ACCDEFC
    NO OF SAME STRING MATCHES IS : 5

    na ka come up in this idea pero wrong iyang flow sa program ug logic ug concept to come up sa right solution




    import java.util.*;

    public class StackDemo{


    public static Scanner console = new Scanner(System.in);
    public static void main(String[] args) {


    String item;

    System.out.print("Enter a String:");
    item = console.next();
    int S[]=new int[10];




    for(int i=0;i<item.length();i++)
    {

    Stack stack=new Stack();
    stack.push("A");
    stack.push("B");
    stack.push(new String(item));


    System.out.print(stack);
    if(stack.size()==0){
    System.out.println("stack is empty");

    }else{

    System.out.println("No.of matches" + stack.size() + "items");
    }

    }
    }
    }

    What do u think guys asa ko na sayop then unsa sad dungag-gan

  2. #2
    store the input string and given string in two Stacks.
    initialize a counter variable to zero
    get a character in Stack A and Stack B one at a time
    compare if the two characters are equal
    if its equal, increment a 'counter' variable
    repeat until both stacks are empty
    display counter

  3. #3
    import java.util.*;
    import java.util.Stack;

    public class StackDemo{


    public static Scanner console = new Scanner(System.in);
    public static void main(String[] args) {


    String item="ABCDEFG";

    System.out.print("Enter a String:");
    item = console.next();




    for(int i=0;i<item.length();i++)
    {

    Stack stack=new Stack();


    item = console.next();


    stack.push(new String(item));





    System.out.print(stack);


    if(stack.size()==0||stack.size=="a"){
    //System.out.println("stack is empty");

    }else{

    System.out.println("No.of matches" + stack.size() + "items");
    }


    }
    }
    }

  4. #4
    Quote Originally Posted by skeptic_rob View Post
    /*design a parser that parse the given string and counts the number of characters that match the given data..using stack or queue ..*/

    ex.
    Given String : ABCDEFG
    INPUT STRING : ACCDEFC
    NO OF SAME STRING MATCHES IS : 5

    na ka come up in this idea pero wrong iyang flow sa program ug logic ug concept to come up sa right solution




    import java.util.*;

    public class StackDemo{


    public static Scanner console = new Scanner(System.in);
    public static void main(String[] args) {


    String item;

    System.out.print("Enter a String:");
    item = console.next();
    int S[]=new int[10];




    for(int i=0;i<item.length();i++)
    {

    Stack stack=new Stack();
    stack.push("A");
    stack.push("B");
    stack.push(new String(item));


    System.out.print(stack);
    if(stack.size()==0){
    System.out.println("stack is empty");

    }else{

    System.out.println("No.of matches" + stack.size() + "items");
    }

    }
    }
    }

    What do u think guys asa ko na sayop then unsa sad dungag-gan
    hehehe peth?

  5.    Advertisement

Similar Threads

 
  1. HP Compaq CQ-42 (need your help guys)
    By idk.101 in forum Computer Hardware
    Replies: 2
    Last Post: 10-01-2010, 10:06 AM
  2. Need your help guys... Scam or Not...
    By winly_ang_batang_bronsy in forum General Discussions
    Replies: 28
    Last Post: 08-14-2010, 05:27 PM
  3. Eyes Here! Need your help guys..
    By jmaxpz09 in forum Computer Hardware
    Replies: 7
    Last Post: 09-18-2009, 03:26 AM
  4. Badly need your help guys...
    By KASAAC in forum Family Matters
    Replies: 18
    Last Post: 03-10-2009, 06:48 AM
  5. i need your help guys
    By Queṣ in forum Computer Hardware
    Replies: 6
    Last Post: 08-09-2008, 10:34 PM

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