Write a C# program that inputs a character and checks to see if it is lowercase or not - AQA - GCSE Computer Science - Question 8 - 2021 - Paper 1
Question 8
Write a C# program that inputs a character and checks to see if it is lowercase or not.
Your program should work as follows:
- gets the user to enter a character a... show full transcript
Worked Solution & Example Answer:Write a C# program that inputs a character and checks to see if it is lowercase or not - AQA - GCSE Computer Science - Question 8 - 2021 - Paper 1
Step 1
gets the user to enter a character and store it in a suitable variable
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Console.WriteLine("Please enter a character:");
char userInput = Console.ReadKey().KeyChar;
Step 2
determines if the entered character is a lowercase character
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
if (char.IsLower(userInput)) {
// Lowercase character
}
else {
// Not a lowercase character
}
Step 3
outputs LOWER if the user has entered a lowercase character
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
if (char.IsLower(userInput)) {
Console.WriteLine("LOWER");
}
Step 4
outputs NOT LOWER if the user has entered any other character
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!