Write a method.

2007-09-19 12:04 am
how to qrite a method that will only accept character 'P','O','A','T' which stands for Primary ,O-level, A-level, tertiary Let say lowercase will be acceptable but uppercase will be returned.

回答 (1)

2007-09-23 10:30 am
✔ 最佳答案
You would like to write a program that only accept the four characters. This can be achieved easily by checking the ASCII code of the input characters.

The pseudocode should be like this:
1. Declare a character type named A
2. Accept Input from keyboard and store the result in A
3. Examine ASCII code of A
4. If A is in the set of {'P', 'O', 'A', 'T', 'p', 'o', 'a', 't'} then write uppercase(A), otherwise jump back to step 2.

I don't know if this is what you want. It seems too easy to be asked.
If you have further questions, you are welcome to ask. I can also assist you in Chinese if you like.
參考: Basic Computer Knowledge


收錄日期: 2021-04-23 17:19:18
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070918000051KK01546

檢視 Wayback Machine 備份