Level A. Word

Правка en2, от AyaAbdelmoghith, 2019-07-03 00:48:02

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.

Теги #strings, #implementation, #problem

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский AyaAbdelmoghith 2019-07-03 00:48:02 15
en1 Английский AyaAbdelmoghith 2019-07-02 22:19:48 1181 Initial revision (published)