Write a program to display next lower case characters of input character

Write a program that takes a character as input (a string of length 1), which you should assume is an upper-case character; the output should be the next character in the alphabet.

If the input is 'Z', your output should be 'A'.

Here's what i've done so far but I’m not getting A when I input Z. I’m getting [.

Please help, what am I doing wrong?

input = (input()).upper() for character in input: number = ord(character) + 1 number1 = chr(number) if ord('z'): new_number = ord(character) - 25 number2 = chr(new_number) print(number1)

Write a program to display next lower case characters of input character

Write a program to display next lower case characters of input character
Write a program to display next lower case characters of input character

Get the answer to your homework problem.

Try Numerade free for 7 days

We don’t have your requested question, but here is a suggested video that might help.

'1. Write a Java program that prompts the user to enter a line of text and outputs the number of digits, the number of lower case letter and the number of upper case letter in that text.'

Given a character, the task is to check whether the given character is in upper case, lower case, or non-alphabetic character 
Examples: 
 

Input: ch = 'A' Output: A is an UpperCase character Input: ch = 'a' Output: a is an LowerCase character Input: ch = '0' Output: 0 is not an aplhabetic character

Approach: The key to solving this problem lies in the ASCII value of a character. It is the simplest way to find out about a character. This problem is solved with the help of the following detail: 
 

#include<bits/stdc++.h>

using namespace std;

void check(char ch)

{

    if (ch >= 'A' && ch <= 'Z')

        cout<< ch << " is an UpperCase character\n";

    else if (ch >= 'a' && ch <= 'z')

    cout<< ch << " is an LowerCase character\n";

    else

        cout<< ch << " is not an aplhabetic character\n";

}

int main()

{

    char ch;

    ch = 'A';

    check(ch);

    ch = 'a';

    check(ch);

    ch = '0';

    check(ch);

    return 0;

}

#include <stdio.h>

void check(char ch)

{

    if (ch >= 'A' && ch <= 'Z')

        printf("\n%c is an UpperCase character",

               ch);

    else if (ch >= 'a' && ch <= 'z')

        printf("\n%c is an LowerCase character",

               ch);

    else

        printf("\n%c is not an aplhabetic character",

               ch);

}

int main()

{

    char ch;

    ch = 'A';

    check(ch);

    ch = 'a';

    check(ch);

    ch = '0';

    check(ch);

    return 0;

}

class GFG

{

    static void check(char ch)

    {

        if (ch >= 'A' && ch <= 'Z')

            System.out.println("\n" + ch +

                    " is an UpperCase character");

        else if (ch >= 'a' && ch <= 'z')

            System.out.println("\n" + ch +

                    " is an LowerCase character" );

        else

            System.out.println("\n" + ch +

                    " is not an aplhabetic character" );

    }

    public static void main(String []args)

    {

        char ch;

        ch = 'A';

        check(ch);

        ch = 'a';

        check(ch);

        ch = '0';

        check(ch);

    }

}

def check(ch):

    if (ch >= 'A' and ch <= 'Z'):

        print(ch,"is an UpperCase character");

    elif (ch >= 'a' and ch <= 'z'):

        print(ch,"is an LowerCase character");

    else:

        print(ch,"is not an aplhabetic character");

ch = 'A';

check(ch);

ch = 'a';

check(ch);

ch = '0';

check(ch);

using System;

class GFG

{

    static void check(char ch)

    {

        if (ch >= 'A' && ch <= 'Z')

            Console.WriteLine("\n" + ch +

                    " is an UpperCase character");

        else if (ch >= 'a' && ch <= 'z')

            Console.WriteLine("\n" + ch +

                    " is an LowerCase character" );

        else

            Console.WriteLine("\n" + ch +

                    " is not an aplhabetic character" );

    }

    public static void Main(String []args)

    {

        char ch;

        ch = 'A';

        check(ch);

        ch = 'a';

        check(ch);

        ch = '0';

        check(ch);

    }

}

<?php

function check($ch)

{

    if ($ch >= 'A' && $ch <= 'Z')

        print($ch . " is an UpperCase character\n");

    else if ($ch >= 'a' && $ch <= 'z')

        print($ch . " is an LowerCase character\n");

    else

        print($ch . " is not an aplhabetic " .

                               "character\n");

}

$ch = 'A';

check($ch);

$ch = 'a';

check($ch);

$ch = '0';

check($ch);

?>

<script>

      function check(ch) {

        if (ch >= "A" && ch <= "Z")

          document.write(ch +

          " is an UpperCase character <br>");

        else if (ch >= "a" && ch <= "z")

          document.write(ch +

          " is an LowerCase character <br>");

        else document.write(ch +

        " is not an aplhabetic character <br>");

      }

      var ch;

      ch = "A";

      check(ch);

      ch = "a";

      check(ch);

      ch = "0";

      check(ch);

</script>

OutputA is an UpperCase character a is an LowerCase character 0 is not an aplhabetic character

Time Complexity: O(1) as it is doing constant operations
Auxiliary Space: O(1)

islower() – check whether a character is lowercase.

isupper() – check whether a character is uppercase.

Below is the implementation of the above approach.

#include <bits/stdc++.h>

using namespace std;

void check(char ch)

{

    if (isupper(ch))

        cout << ch << " is an UpperCase character\n";

    else if (islower(ch))

        cout << ch << " is an LowerCase character\n";

    else

        cout << ch << " is not an aplhabetic character\n";

}

int main()

{

    char ch;

    ch = 'A';

    check(ch);

    ch = 'a';

    check(ch);

    ch = '0';

    check(ch);

    return 0;

}

OutputA is an UpperCase character a is an LowerCase character 0 is not an aplhabetic character

Time Complexity: O(1)
Auxiliary Space: O(1)