Question: Write a function that returns the order of a character in the alphabet ( e . g . , its position ) . Letter A

Write a function that returns the order of a character in the alphabet (e.g., its position). Letter A is 0,B is 1,C is 2,dotsZ is 26. The function accepts a character ch and returns its position in the alphabet. NOTE that the Ifunction should return the same order regardless of upper or lower case. So,'A' and 'a' both should return 0.
An easy way to do this is to remember that characters are represented by numerical code. So, the letter 'A' has a number associated with it. Thus ch -'A' would return 0 if ch is 'A',1 if it was 'B', etc. Remember to do the appropriate computation for both upper and lower case letters.
Examples:
charPosition('M')12
charPosition('A')0
charPosition(''a')0
Your Answer:
public int charPosition(char ch)
f
}
 Write a function that returns the order of a character in

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!