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
emmasim [6.3K]
2 years ago
6

(Display characters) Write a method that prints characters using the following header: public static void printChars(char ch1, c

har ch2, int numberPerLine) This method prints the characters between ch1 and ch2 with the specified numbers per line. Write a test program that prints ten characters per line from 1 to Z. Characters are separated by exactly one space.
Computers and Technology
2 answers:
Butoxors [25]2 years ago
6 0

Answer:

Written in Java

public static void printChars(char ch1, char ch2, int numberPerLine){

        int i = 1;

        for(char A = ch1; A <= ch2; A++){

            if(i<=numberPerLine){

               System.out.print(A+" ");    

               i++;

            }

            else{

                System.out.println();

                i = 1;

            }

        }

    }

Explanation:

This line defines the method

public static void printChars(char ch1, char ch2, int numberPerLine){

This line initializes the number of print out per line to 1

        int i = 1;

The following is an iteration that prints from ch1 to ch2. Note that ch1 and ch2 are characters

        for(char A = ch1; A <= ch2; A++){

The following if condition (italicized) checks if the number of print outs is up to the required length.

If No, the character is printed

If yes, a new line is printed.

      <em>      if(i<=numberPerLine){</em>

<em>                System.out.print(A+" ");    </em>

<em>                i++;</em>

<em>             }</em>

<em>             else{</em>

<em>                 System.out.println();</em>

<em>                 i = 1;</em>

<em>             }</em>

        }

    }

See attachment for full program including test of ten characters in a line

Download txt
Juli2301 [7.4K]2 years ago
5 0

public class MyClass {

   public static void printChar(char ch1, char ch2, int numberPerLine){

       int i = 0;

       for (char c = ch1; c <= ch2; c++){

           while (i < numberPerLine){

               System.out.print(c + " ");

               i += 1;

           }

           System.out.println("");

           i = 0;

       }

   }

   public static void main(String args[]) {

     printChar('a', 'z', 10);

   }

}

So far, this works by printing letters. If you need me to modify the code, I will.

You might be interested in
I made a fish emoji what do you think &gt;{'_'}&lt; should I change anything
Anvisha [2.4K]

Answer: It is beautiful

Explanation:

3 0
3 years ago
Read 2 more answers
Which of these categories of computer software can add thousands of dollars to the cost of a computer system?
Radda [10]
Specialized software. hope this helps
6 0
3 years ago
Welcome to Cypres...
Debora [2.8K]

Answer:

<em>sorry</em><em> </em><em>I </em><em>don't</em><em> </em><em>know</em><em> </em><em> </em><em>I </em><em> </em><em>can't</em><em> </em><em>will</em><em> </em><em>your</em><em> </em><em>help</em>

5 0
3 years ago
well im a gamer and i wait for a while befoer i accept a friend request from someone i know so i think its A
mamaluj [8]
What is your question though?
7 0
3 years ago
Prime numbers can be generated by an algorithm known as the Sieve of Eratosthenes. The algorithm for this procedure is presented
Sidana [21]

Answer:

const MAXNR=150;

let candidates = {};

for(let i=2; i<=MAXNR; i++) {

   candidates[i] = true;

}

for(let p=2; p <= MAXNR; p++) {

   if (candidates[p]) {

       process.stdout.write(`${p} `);

       // Now flag all multiples of p as false

       i=2;

       while(p*i <= MAXNR) {

           candidates[p*i] = false;

           i++;

       }

   }

}

4 0
3 years ago
Other questions:
  • Paragraph: Read the following two e-mail messages. In three to five sentences, explain why E-mail B is the more appropriate work
    5·1 answer
  • Write a program using Python that prompts for an integer and prints the integer, but if something other than an integer is input
    11·2 answers
  • [20 pts] Write the function rectangle(perimeter, area), which takes two positive integers, perimeter and area. It returns an int
    11·1 answer
  • Which is a circuit board located behind an LCD screen on a laptop?
    7·1 answer
  • Swiping and pinching are graphical user interface (gui) _____________.
    7·2 answers
  • Consider two communication technologies that use the same bandwidth, but Technology B has twice the SNR of technology A. If tech
    14·1 answer
  • What sorts of changes have you been observing in your society in your society in comparison in last 3 years​
    13·1 answer
  • Start
    14·1 answer
  • Levi wants to run 5 commands sequentially, but does not want to create a shell script. He knows that each command is going to ta
    5·1 answer
  • Integrity constraints are enforced by Group of answer choices A. The operating system B. The end user C. The database designer D
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!