java - How can I make my main if, elseIf and else to do the same thing as my main if does without getting "duplicate" errors? -


my main if statement asks input. if it's "february",it goes next steps. want these same steps main elseif , else after own part. want convert "february" "alluppercase" or "alllowercase" make insensitive. error when i'm writing ""if(s1.tolowercase("february"))"" thanks

import java.io.bufferedreader; import java.io.inputstreamreader; import java.util.arrays;  public class compare {  public static void main(string[] args) {     string[] months1 = {"january","march","april","may","june","july","augest","september","october","november","december"};     string s1 = getinput("enter month ");     if(s1.equals("february")) {         system.out.println("it's time go disneyland !");         string s2 = getinput("enter month: ");         if(s2.equals("february")) {             system.out.println("you won disneyland ticket! try month.");             string s3 = getinput("enter month: ");             string[] months = {"january","march","april","may","june","july","augest","september","october","november","december"};                            if(arrays.aslist(months).contains(s3.tolowercase())) {                   system.out.println("you go paris");             }else{                  string s4 = getinput("leave name , phone number. call back. ");                  system.out.println("thanks visiting! goodbye !" + s4);             }             }     }else if(arrays.aslist(months1).contains(s1.tolowercase())){         system.out.print("sorry don't have specials yet");      }else{         system.out.print("phahaha:))) choose sthg else");     }  }             private static string getinput(string prompt) {                 bufferedreader stdin = new bufferedreader(                 new inputstreamreader(system.in));                 system.out.print(prompt);                 system.out.flush();      try {         return stdin.readline();     } catch (exception e) {         return "error: " + e.getmessage();       }   } 

}

yes indeed if(s1.tolowercase("february")) compile error since s1.tolowercase("february") returns string , if () expects boolean.

use if(s1.equalsignorecase("february")) ` compare string ignoring case


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -