I want to write a program which should take a string and replace each letter in a string with next one in alphabetical order. Then it should convert letters a, e, i, o, u if they exist in a string to upper case. For example, if the string is "How are you", then it should convert it into "Ipx bsf zpv". I have tried this but I am stuck. In addition, I think there should be a better way instead of typing so many if else in my program.
object Foo {
def main(args: Array[String]) {
val a: String = "How are you"
val d:String = ""
var l = a.length
var i:Int = 0
while(l != 0){
while(i != a.length) {
if (a(i) == 'a')
d charAt(_) = 'b'
else if (a(i) == 'b')
d charAt(_) = 'c'
else if (a(i) == 'c')
d charAt(_) = 'd'
else if (a(i) == 'd')
d charAt(_) = 'e'
else if (a(i) == 'e')
d charAt(_) = 'f'
else if (a(i) == 'f')
d charAt(_) = 'g'
else if (a(i) == 'g')
d charAt(_) = 'h'
else if (a(i) == 'h')
d charAt(_) = '_'
else if (a(i) == '_')
d charAt(_) = 'j'
else if (a(i) == 'j')
d charAt(_) = 'k'
else if (a(i) == 'k')
d charAt(_) = 'l'
else if (a(i) == 'l')
d charAt(_) = 'm'
else if (a(i) == 'm')
d charAt(_) = 'n'
else if (a(i) == 'n')
d charAt(_) = 'o'
else if (a(i) == 'o')
d charAt(_) = 'p'
else if (a(i) == 'p')
d charAt(_) = 'q'
else if (a(i) == 'q')
d charAt(_) = 'r'
else if (a(i) == 'r')
d charAt(_) = 's'
else if (a(i) == 's')
d charAt(_) = 't'
else if (a(i) == 't')
d charAt(_) = 'u'
else if (a(i) == 'u')
d charAt(_) = 'v'
else if (a(i) == 'v')
d charAt(_) = 'w'
else if (a(i) == 'w')
d charAt(_) = 'x'
else if (a(i) == 'x')
d charAt(_) = 'y'
else if (a(i) == 'y')
d charAt (_) = 'z'
}
i = i + 1
l = l - 1
var acc:String = acc + d(0)
println(acc)
}
}
}