+ 1

Why my code isnt running? Error: symbol not found

System.out.println(" CURRENCY CONVERTOR "); Scanner sc = new Scanner(System.in); System.out.println(" ENTER THE CURRENCY YOU WANT TO CONVERT"); System.out.println(); String currency1 = sc.nextLine(); System.out.println(" ENTER THE CURRENCY YOU WANT TO CONVERT TO "); String currency2 = sc.nextLine(); System.out.println(); if(currency1==DOLLAR && currency2==RUPPEE){ float x=sc.nextFloat(); float y= x*82; System.out.println(y); } else if(currency1==RUPPEE && currency2==DOLLAR){ float x=sc.nextFloat(); float y=x/82; System.out.println(y); } else if(currency1==POND && currency2==RUPPEE){ float x=sc.nextFloat(); float y=x*99; System.out.println(y); }

27th Feb 2023, 5:40 AM
Shubham Swaraj 161
Shubham Swaraj 161 - avatar
5 Answers
+ 2
Shubham Swaraj 161 Java is case sensitive language. "DOLLAR", "Dollar", "dollar", ... are different values because having value with capital letters only or small letters, or mix of both. If you use equalsIngoreCase() method then you can input any of these values without bothering capitalizations. equals() method checks all for case matching strictly...
27th Feb 2023, 6:41 AM
Jayakrishna šŸ‡®šŸ‡³
+ 2
Thank you so much Mr Jayakrishna, it worked! Adding one last question , what is case ignorance! Jayakrishna šŸ‡®šŸ‡³
27th Feb 2023, 6:29 AM
Shubham Swaraj 161
Shubham Swaraj 161 - avatar
27th Feb 2023, 6:00 AM
Shubham Swaraj 161
Shubham Swaraj 161 - avatar
+ 1
What are DOLLAR , RUPEE, EUROs? You did not defined anywhere.. See "DOller" is a string, enclosed in double quotes where as Doller is a variable , as per compiler recognition. Either declare it as String DOLLER = "DOLLER" or use it by enclosing in quotes. And for string Comparisions, use equals() method instead of ==. == compares references, not value. So use corrency1.equals("DOLLAR") For, case ingorence, use corrency1.equalsIngoreCase("RUPEE") edit: Shubham Swaraj 161 You are declared x, y twice. declare only once. you declared at begin as float x, y; then no need again declare in every if-else block. just use it without float type. import Scanner object. import java.util.Scanner; try these changes..
27th Feb 2023, 6:12 AM
Jayakrishna šŸ‡®šŸ‡³
0
Save full code in playground and share link. That helps to debug it easily...
27th Feb 2023, 5:55 AM
Jayakrishna šŸ‡®šŸ‡³