1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Minchanka [31]
3 years ago
15

Given an alphabet, print all the alphabets up to and including the given alphabet.

Computers and Technology
2 answers:
sergij07 [2.7K]3 years ago
6 0

Answer:

  //Write the printAlphaber method header;

   //It takes a char as parameter and has a return type of void

   public static void printAlphabet(char ch){

       

       //Every char has its ASCII number representation

       //For example, char 'A' = 65, 'B' = 66, 'a' = 97, 'c' = 99

       //In essence, A to Z = 65 to 90 and a to z = 97 to 122

       //Also, if comparing a char with an int will compare the ASCII representation of the char with the int

       //For example, 'A' == 65 will return true.

       //Using this technique, let's write an if..else statement that checks

       //if char ch is between 65 and 90 both inclusive.  

       //If ch is between 65 and 90, then it is an uppercase letter  

       if(ch >= 65 && ch <=90){

           

           //Therefore, write a for loop to print all capital letters from 65(which is A) to char

           //starting from i=65 and ending at i=ch

           for(int i = 65; i <= ch; i++){

               //print the char representation of the ASCII number

               //by type casting the ASCII number to a char

               System.out.print((char)i);

               

               //attempt to print a space char if i is not the last letter in the sequence

               if (i != ch){

                   System.out.print(" ");

               }

           }    

       }

                 

       //If ch is between 97 and 122 both inclusive, then it is a lowercase letter

       else if(ch >= 97 && ch <= 122){

           

           //Therefore, write a for loop to print all capital letters from 97(which is a) to char

           //starting from i=97 and ending at i=ch

           for(int i = 97; i <= ch; i++){

               

               //print the char representation of the ASCII number

               //by type casting the ASCII number to a char

               System.out.print((char)i);

               if (i != ch){

                   System.out.print(" ");

               }

           }  

       }

       

       else{

           System.out.println("");

       }

   }        // End of method printAlphabet

<h2>Sample Output:</h2>

<em><u>When printAlphabet is called with d i.e printAlphabet('d')</u></em>

>> a b c d

<em><u>When printAlphabet is called with K i.e printAlphabet('K')</u></em>

>> A B C D E F G H I J K

<h2>Explanation:</h2>

The code above has been written in Java and it contains comments explaining every segment of the code. Please kindly read the comments carefully. The source code file for the complete application has been attached to this response. Kindly download it.

<u><em>The code without comments</em></u>

   public static void printAlphabet(char ch){

       if(ch >= 65 && ch <=90){

           for(int i = 65; i <= ch; i++){

               System.out.print((char)i);

               if (i != ch){

                   System.out.print(" ");

               }

           }    

       }

                 

       else if(ch >= 97 && ch <= 122){

             for(int i = 97; i <= ch; i++){

               System.out.print((char)i);

                if (i != ch){

                   System.out.print(" ");

                }

           }  

       }

       

       else{

           System.out.println("");

       }

   }        // End of method printAlphabet

Download java
anastassius [24]3 years ago
5 0

Answer:

Explanation:

public void printAlphabets(char c){

    String capitals = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    String small = "abcdefghijklmnopqrstuvwxyz";

    if(capitals.contains(""+c)){

        for(int i=0; i<capitals.length();i++){

            if (capitals.charAt(i)!=c)

                System.out.print(capitals.charAt(i)+" ");

            else

                break;

        }// end for

        System.out.print(c);

    }else if (small.contains(""+c)){

        for(int i=0; i<small.length();i++){

            if (small.charAt(i)!=c)

                System.out.print(small.charAt(i)+" ");

            else

                break;

        }// end for

        System.out.print(c);

    }// end else if

}// end printAlphabets method

You might be interested in
I have the assembly for the max. can someone change the variables of it and make it min. I mean, the assembly for finding the mi
tatyana61 [14]
Bruh i honeselty dont know
4 0
3 years ago
Given that a function receives three parameters a, b, c, of type double , write some code, to be included as part of the functio
hoa [83]

Answer:

   public static void quad(double a, double b, double c) {

       double D = (Math.pow(b, 2)) - (4 * a * c);

       if (D<0){

           System.out.println("no real solutions");

       }

   }

Explanation:

The code snippet above implements the function in Java programming language

As required by the question, the line  double D = (Math.pow(b, 2)) - (4 * a * c); evaluates b squared" - 4ac and assignes the value to the variable D

An if statement is used to test if D is less than 0, if this is true the message no real solutions is printed

5 0
3 years ago
Favorite video games list atleast 5<br><br> favorite to least
Aneli [31]

Answer:

Rob lox, Sub nautica, Phasmo phobia, Albion Online,  fnf.

Explanation:

6 0
3 years ago
A company wants to ensure that the validity of publicly trusted certificates used by its web server can be determined even durin
Natali [406]

Answer: OCSP

Explanation:

Ocsp(online certificate status protocol) is used to maintain the security status of the server and also to determine the status of SSL/TLS certificates used by the webserver.

5 0
3 years ago
Develop a spreadsheet that compares the features, initial purchase price, and a two-year estimate of operating costs (paper, car
antiseptic1488 [7]

Answer:

dgfdghvcsdhjccxadhhvcsdhjvczafjmbd FYI jjgdc

3 0
3 years ago
Other questions:
  • IF YOU KNOW THE ANSWER TO THIS PLEASE ANSWER ASAP
    12·1 answer
  • Jordan has been asked to help his company find a way to allow all the workers to log on to computers securely but without using
    6·1 answer
  • Given a integer, convert to String, using String Builder class. No error checking needed on input integer, However do read in th
    11·1 answer
  • What are the two ways to use the help menu
    9·2 answers
  • Mac or PC (need opinions please)<br><br> Why did you choose Mac/PC?
    10·2 answers
  • Numdu
    7·1 answer
  • Write bash script which takes array as an input of size 10 bind its even indexes to accept even values and odd indexes to accept
    5·1 answer
  • Henry has created a software product that manages a database of company clients. He wants to install the software on a client's
    13·1 answer
  • write a function that returns a list, where each member of list contains previous day’s value multiplied by 2.​
    15·1 answer
  • Question is in photo
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!