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
// Declare a variable to hold the input character
char inputChar;
// Prompt the user for input
Console.WriteLine("Please enter a character:");
// Read input and store it
inputChar = 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
// Check if the character is lowercase
if (char.IsLower(inputChar)) {
// If it is lowercase, output LOWER
Console.WriteLine("LOWER");
} else {
// If it is not lowercase, output NOT LOWER
Console.WriteLine("NOT LOWER");
}