What is the error in this code??? | Sololearn: Learn to code for FREE!


What is the error in this code???

I have created a program on Morse code using switch case. Upon entering multiple letters, it prints the Morse code of only the first one. https://code.sololearn.com/c8Ih0bpblNmI/?ref=app https://code.sololearn.com/c8Ih0bpblNmI/?ref=app

11/24/2019 10:33:01 AM


4 Answers

New Answer




Thank you so much Sami Khan & ~swim~ for your answers. The program worked!!😃😃


You need to put the whole switch in a loop. Currently the switch is statement is executed only once.


use .toLowerCase(); and check only lower letters String s= n.nextLine().toLowerCase(); ... switch(s.charAt(g)) { //case 'A': case 'a': System.out.print ("•- ");break;