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
At a local burger chain, a customer became extremely angry. Everyone took notice at the person, who was yelling at anyone he cou
leonid [27]

Answer: Donald, the branch manager displayed people skills  

Explanation: People skills are a combination of behavior and behavioral interactions between people. There are many abilities that fall under the category of people skills, for example, personal effectiveness, interactive skills and negotiation skills. While the customer was shouting, Donald patiently heard and tried to calm the customer which reflected that he respected and valued the customer and kept a positive behavior towards the customer.


5 0
3 years ago
Read 2 more answers
after clicking the start button on your computer screen desktop what option would you then select to examine system components y
Len [333]
Start>hover over "Computer">right-click>Properties>shows system specs

Start>Control Panel>lets you modify network connections, change time and date, update, uninstall programs, add new hardware, etc.
7 0
2 years ago
When creating an electronic slide presentation, Lee should avoid
Amanda [17]

I believe the answer is <u>Using sound effects between slides.</u>

Using sound effects between slides can cause for a distraction, and if you are in college, your professor may not score your presentation as well as if it were made without sound effects. Hope this helps!

5 0
2 years ago
How has the global marketplace used emerging technologies to expand businesses
madam [21]

Answer:

Information Technology (IT) has revolutionized the way organizations conduct business by enabling small and medium businesses to level the playing field with larger organizations. Small businesses use an array of technology based on everything from computer server stations to portable mobile devices to expand competitive advantages in the global economic marketplace and marketing environment. So, small & medium business organizations owners are considering implementing information technology (IT) in their planning process for streamlined integration. Thus, this process is leading to future business expansion locally as well as globally. This decision allows proprietors to create smooth business operations using the most effective information technology available. On the other hand, the Internet has further linked the overseas suppliers of goods and services and their buyers. During the e-commerce era, internet traffic is increasing day by day, and e-commerce business is in the hyper growth stage. Information technology tremendously helps to boost the expansion of the current and future of marketing environment; communication technology became faster than ever. Though, globalization creates a little challenge for multinational companies to share resources and knowledge across a number of businesses inside and outside the country. Outsourcing and freelancer ease this challenge because multinational companies recruit talent freelancers and outsource their projects to the highly expert vendors and then the works are done through the team of people very effectively and efficiently.

Explanation:

6 0
2 years ago
What is your favorite LEGO set
alekssr [168]

Answer:

star wars death star....

4 0
3 years ago
Read 2 more answers
Other questions:
  • When pasting an object which has been copied from a different slide, where on the slide does the object paste, assuming nothing
    15·1 answer
  • Which is a function of network media?
    14·2 answers
  • Security awareness training can reduce the risk of a data breach by what percentage?
    12·1 answer
  • How can i complain a rude comment
    7·1 answer
  • 1. What are copyright laws? (6 points)
    15·1 answer
  • Linda is viewing the campaign report in her Google Ads account after successfully implementing conversion tracking tags for her
    7·1 answer
  • Which screen should be open to customize or personalize a desktop background?
    15·2 answers
  • An automatic transmission is a mechanism that _
    7·1 answer
  • What are the significances of blogs?
    7·2 answers
  • Which of the following is a characteristic of vector graphics?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!