AyaAbdelmoghith's blog

By AyaAbdelmoghith, history, 5 years ago, In English

Here is the problem question ~~~~~ import java.util.Scanner;

public class Word {

public static void main(String[] args) {

    Scanner input = new Scanner (System.in);
    String str=input.next();
    int lower=0;
    int upper=0;

    //System.out.println(str);
    for (int i=0 ;i<str.length();i++) {
       int num=str.charAt(i) ;
       System.out.println(num);
       if (num>= 97 || num<= 122 )  {
         lower++;
         System.out.println(lower+"L");}
       else //if (num>= 65 || num<= 90 )
         {
         upper++;
         System.out.println(upper+"U");
       }}
    System.out.println(lower +" "+ upper);
    if (lower>= upper)
       str=str.toLowerCase();

    else //if (lower<upper)
       str=str.toUpperCase();
    System.out.println(str);
    input.close();
}

}

~~~~~ I have no idea why my output comes out as lowercase only! beside please, if you see that I need a bit of advice to improve myself at PS don't hesitate to tell me so because while I am reading the question I know 100% that the answer is so easy and I am struggling to find a solution to the problem. I am solving currently at level A.

Thanks All.

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By AyaAbdelmoghith, history, 5 years ago, In English

[ This is my code, I check it on Eclipse (The program I use to code) it works. However, I submitted here it doesn't work.][Here is the problem question](http://codeforces.com/contest/677/problem/A) ~~~~~ import java.util.Scanner;

public class AntonandDanik {

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    Scanner string = new Scanner(System.in);
    int noGames= input.nextInt();
    String name = string.nextLine();//name.length()
    name=name.toUpperCase();
    int countA=0;
    int countD=0;
    char winner;
    for (int i=0; i<noGames;i++){
       winner= name.charAt(i);
       if (winner == 'A')
         countA++;
       else if (winner == 'D')
         countD++;
    }

    if (countA > countD)
       System.out.println("Anton");
    else if (countA < countD)
       System.out.println("Danik");
    else if (countA == countD)
       System.out.println("FriendShip");


}

} ~~~~~

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it