-1

I am trying to create the following program in which I need to turn the input String's characters into lowercase to ease my work.

I tried using toLowerCase(); first but it didn't work. Then I tried using toLowerCase(locale); and yet I have not succeeded.

public static void  Mensuration() {
    Locale locale = Locale.ENGLISH;
    Scanner inputz = new Scanner(System.in);
    System.out.println("Which kind of shape's formula would you like to find out.2D or 3D?");
    char dimension = inputz.nextLine().charAt(0);
    if(dimension == '2') {System.out.println("Okay so which shape?");
    String dimensiond = inputz.nextLine().toLowerCase(locale);
    if(dimensiond == "rectangle") {System.out.println("Area = length x breadth\nPerimeter = 2(length + breadth)");}
        }
        }

I expected the program to give the accurate output but the thing that happens is that there is no output actually!!

Popeye
  • 11,839
  • 9
  • 58
  • 91
  • there is nothing wrong with how you put your input to lowerCase, just your comparison, as Guy points out. – Stultuske May 07 '19 at 11:51

1 Answers1

0

use equals to compare strings. I think this causing the error

"rectangle".equals(dimensiond)
Ankit Deshpande
  • 3,476
  • 1
  • 29
  • 42