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
1. A database table can hold ??
IRINA_888 [86]

Answer:

who are interested and I have been trying to

3 0
3 years ago
Difference between implicit and explicit type casting
Lana71 [14]

Answer:

Implicit type casting means the type casting done by the compiler during compilation of program whereas Explicit type casting means the programmer explicitly type casts the variables. This is the difference implicit and explicit type casting.

Explanation:

Type casting means the conversion of one data type into another data type. There are two types of type casting. They are Implicit type casting and Explicit type casting.

<u>Implicit type casting:</u> The type casting which is done by the compiler during the compilation of a program. This occurs when we assigning smaller data type to larger data type and also both the data type are compatible. Below example clears the above concepts.

Ex: int \, i = 10;

long \, l = i;

In the above example " i "  is " int " data type whereas  " l " is long data type but as we assigned the value of " i " to " l ". Here " int " and " long " are compatible data types and we assigned smaller data type ( int - i ) to larger data type  ( long - l ) implicit type casting occurs.

<u>Explicit type casting:</u> The type casting which is done by the programmer explicitly to convert one data type into other data type. If we want to assign a value of larger data type to smaller data type explicit type casting is required. Below example clears the above concepts.

Ex: double \, d = 10.4;

long\, l = (long) d;

In the above example " d " is " double " data type whereas " l " is " long " data type. Here we are explicitly type casting to change larger data value ( double - d ) to smaller data value ( long - l ).  

7 0
3 years ago
Read 2 more answers
100 POINTS + BRAINLYEST TO FIRST PERSON THAT IS CORRECT!!! Which items can be found in the Properties section of the Backstage V
Lunna [17]

Print settings

author off document

how many times it has been viewed

4 0
2 years ago
Read 2 more answers
What type of socket should be used with an air impact wrench
Vikentia [17]
<span>Black sockets should be used, but the color is not the reason why. Chrome sockets will cause splits to form in the socket walls pretty quickly, after only a few uses. But the black sockets are that color because they have gone through a process called Parkerizing that coats the surface of the socket in order to provide more resistance when being used and protect the socket against corrosion.</span>
3 0
3 years ago
What is a “spoof” of an ad ?
kykrilka [37]
I think a spoof of an ad is the study of an ads rhetorical devices that is what I think I am not completely sure
5 0
3 years ago
Read 2 more answers
Other questions:
  • In the 2007/2010 version of Paint, which of the following tools are located in the View tab? (Select all that apply.)
    5·1 answer
  • Troubleshooting a printer that does not work includes a. connecting the printer to your computer b. checking to see if there is
    13·1 answer
  • Which of the following is most likely to be a result of hacking? Group of answer choices slowing of network speed certain Web si
    13·1 answer
  • Now tell me how be rich like Bill Gates
    6·1 answer
  • Availability is an essential part of ________ security, and user behavior analysis and application analysis provide the data nee
    14·1 answer
  • A file named numbers.txt contains an unknown number of lines, each consisting of a single positive integer. Write some code that
    6·1 answer
  • What is computer code?<br> A. Java Script<br> B. XML<br> C. HTML<br> D. Any programming language
    6·1 answer
  • Assume that you have the business data in various sources such as Excel, .csv, text files and Access, Oracle databases. Write th
    9·1 answer
  • A folder is a collection of related of data is true or false​
    10·2 answers
  • Being a part of an organization or giving back to the community is which rewards of work factor?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!