Results 1 to 4 of 4

Thread: Ahmed Aly

  1. #1
    Join Date
    Aug 2014
    Posts
    6
    Rep Power
    0

    Default Ahmed Aly

    Hi for all!
    I have some mistakes in this problem.
    The link of the problem:
    Ahmed Aly

    This is my work:
    Java Code:
    import java.util.Scanner;
    class Maine{
    public static void main(String[]args){
    String chaine[]=new String[100];
    String result[]=new String[100];
    Scanner sc=new Scanner(System.in);
    int T=sc.nextInt();
    sc.nextLine();
    for(int i=0;i<T;i++)
    chaine[i]=sc.nextLine();
    int j=0;
    for(int i=0;i<T;i++){
    String equation=new String(chaine[i]);
    while(equation.charAt(j)!='=')
    i++;
    int k;
    String partg=new String("");
    partg=partg+equation.charAt(j);
    String elg=new String("");
    while(partg.charAt(k)!='+'){
    elg=elg+partg.charAt(k);
    }
    int cpt=(k+2);
    String eld=new String("");
    for(int l=cpt;l<=partg.length();l++)
    eld=eld+partg.charAt(l);
    int cpt2=(cpt+2);
    String partd=new String("");
    for(int m=cpt2;m<=equation.length();m++){
    partd=partd+equation.charAt(m);
    int X,Y,Z;
    X=Integer.parseInt(elg);
    Y=Integer.parseInt(eld);
    Z=Integer.parseInt(partd);
    if((X+Y)==Z)
    result[i]="YES";
    else result[i]="NO";
    for(int w=0;w<T;w++)
    System.out.println("Case "+i+": "+result[i]);
    }
    }
    }
    Thanks in advance

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Ahmed Aly

    Copy and paste the full error message. Also post code that has been indented properly.

  3. #3
    Join Date
    Aug 2014
    Posts
    6
    Rep Power
    0

    Default Re: Ahmed Aly

    Quote Originally Posted by Junky View Post
    Copy and paste the full error message. Also post code that has been indented properly.
    The error is in the last line .It concerns }

  4. #4
    AlexGraal is offline Señor Member
    Join Date
    Jan 2014
    Posts
    184
    Rep Power
    0

    Default Re: Ahmed Aly

    import java.util.Scanner;
    class Maine{ <<<<<<<<<
    public static void main(String[]args){ <<<<<<<<<<<
    String chaine[]=new String[100];
    String result[]=new String[100];
    Scanner sc=new Scanner(System.in);
    int T=sc.nextInt();
    sc.nextLine();
    for(int i=0;i<T;i++)
    chaine[i]=sc.nextLine();
    int j=0;
    for(int i=0;i<T;i++){ <<<<<<<<<<<
    String equation=new String(chaine[i]);
    while(equation.charAt(j)!='=')
    i++;
    int k;
    String partg=new String("");
    partg=partg+equation.charAt(j);
    String elg=new String("");
    while(partg.charAt(k)!='+'){ <<<<<<<<<<<<
    elg=elg+partg.charAt(k);
    } >>>>>>>>>>>>>>>>>>>
    int cpt=(k+2);
    String eld=new String("");
    for(int l=cpt;l<=partg.length();l++)
    eld=eld+partg.charAt(l);
    int cpt2=(cpt+2);
    String partd=new String("");
    for(int m=cpt2;m<=equation.length();m++){ <<<<<<<<<<<<
    partd=partd+equation.charAt(m);
    int X,Y,Z;
    X=Integer.parseInt(elg);
    Y=Integer.parseInt(eld);
    Z=Integer.parseInt(partd);
    if((X+Y)==Z)
    result[i]="YES";
    else result[i]="NO";
    for(int w=0;w<T;w++)
    System.out.println("Case "+i+": "+result[i]);
    } >>>>>>>>>>
    } >>>>>>>>>>>>>>
    } >>>>>>>>>>>>>>


    Count with me now.

    5 open brackets, 4 closed brackets. hmmmm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •