answer.
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]
1 year ago
15

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

Computers and Technology
2 answers:
sergij07 [2.7K]1 year 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]1 year 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
Which phrase best describes a scenario in Excel 2016?
Airida [17]

Answer:

what are the phrases?

Explanation:

6 0
1 year ago
Which of the following is a true statement about cloud computing?
Veseljchak [2.6K]

Answer:

There are additional security risks associated with using cloud computing over local data storage.                    

Explanation:

Cloud computing: The term "cloud computing" is described as a process through which an individual tends to access and store various programs and data over the internet rather than his or her computers' "hard drive". However, the term "cloud" here refers to a specific metaphor associated with the internet.

Types:

1. Software-as-a-service or SaaS.

2. Platform-as-a-service or PaaS.

3. Infrastructure-as-a-service or IaaS.

In the question above, the very first option is correct as all other options mentioned over here are incorrect because they aren't related to cloud computing.

3 0
1 year ago
IANA has primarily been responsible with assigning address blocks to five regional internet registries (RIR). A tech needs to re
VikaD [51]

Answer:

The American Registry for Internet Numbers ARIN

Explanation:

The American Registry for Internet Numbers (ARIN) is a not for profit organization that serves as the administrator and distributor of Internet numeric resources such as IP addresses (IPv4 and IPv6) ASN for the United States, Canada, as well as North Atlantic and Caribbean islands

There are four other Regional Internet Registry including APNIC, RIPE NCC, LACNIC and AFRINIC.

6 0
1 year ago
Which statement is correct? a. choice of metric will influence the shape of the clusters b. choice of initial centroids will inf
katrin2010 [14]

Answer: the answer is c

Explanation:in general, the merges and splits in hierarchical clustering are determined in a greedy manner

8 0
1 year ago
Clara writes online articles based on world religions. Her articles have references to dates. Which HTML element will help her d
brilliants [131]

Answer:

Available Options are :

A <b>

B <l>

C <body>

D <small>

Ans : A <b>

Explanation:

Normally AD and BC are written in bold letters.

for example : The terms anno Domini (AD) and before Christ (BC).

Within available option the best option to choose is <b>

The <body> element used to define the document body.

The <small> tag used to defines smaller text

But, the best option to choose is in case if they are using the HTML5  then html <time> element will be used to display BC date and AD dates.

for ex : <time datetime="-314-07-01"

calendar="Ancient Roman">1 July 314 BC</time>

3 0
1 year ago
Other questions:
  • In object oriented programming, what is another name for the "attributes" of an object?
    14·1 answer
  • Which are examples of copyrighted online materials? Check all that apply.
    14·2 answers
  • A good website design combines which of the following elements? (select all that apply) powerful web server hardware components
    9·2 answers
  • James is an employee at the packaging unit of a chocolate factory that has come up with a new concept of packaging and marketing
    11·2 answers
  • Write a copy assignment operator for CarCounter that assigns objToCopy.carCount to the new objects's carCount, then returns *thi
    15·1 answer
  • SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick R
    9·1 answer
  • Write a flowchart and C code for a program that does the following: Within main(), it asks for the user's annual income. Within
    12·1 answer
  • Cloud storage refers to the storage of data on ______.a. your mobile device.b. your desktop computer.c. an external drive.d. a s
    7·1 answer
  • Which is true regarding pseudocode
    8·1 answer
  • A large organization is struggling to close the gaps in skill levels that exist between its employees and those from competing c
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!