+ 1
Why this program not run according to which what i want???
if i write input as like 3 6......so it show exception n if i write input 7 so it is run infinity https://code.sololearn.com/cn9rd6fyZdzR/?ref=app Arun Tomar Fata1 Err0r Helga Hans Larry HAWKEYE Gaurav Agrawal
7 Respuestas
+ 1
https://code.sololearn.com/ccXWdou4hv4g/?ref=app
I've updated the code. You can use charAt() method to retrieve the character at a given index of a string, so 0 will be the first one.
It might also be worth checking out the Character class (easy to find on google) which provides some handy utility methods for characters (like the Integer class that you have used already to parseInt)
Hope this helps :)
+ 2
When you read() the char value and then do a readLine() you'll read the rest of the line you're on, which is an empty string. this can't be parsed to an int and so the error is thrown.
Use an int instead of a char, changing the relevant fields in the switch etc. and change read to readLine and it will work (I tested it on my app)
looks like you want to do the loop when the value is between 1 and 4 and break out of the loop for the condition you have written. an invalid input produces an infinite loop
+ 2
readLine gives a string, so you'd have to parse into a character (read gives an int or byte which is easily coerced into a char). So you'd need to check if the string had size 1. I used ints because it's probably easier but you could make the change I suggested here too
+ 1
https://code.sololearn.com/ccXWdou4hv4g/?ref=app
I'll leave the fixing of the while loop to you :)
0
Dan Walker can u give me d code????
0
but why we dont use char data types! is der any logical error or something
nd if i want to do in with char data types only so what can i do,??
0
Dan Walker can u do it for me!!! so it wll be easy i tried many times with char data types but it show error!!!!
so plzzz do it.......