Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions