Write a JAVA program:
Consider the method displayRowOfCharacters that displays any given character the specified number of times on one line.
For example, the call displayRowOfCharacters(‘*’, 5) produces the line *****
Implement this method by using recursion.
Here is code:
import java.io.*;
import java.util.Scanner;
class DisplayChar
{
public static void main(String []args){
char c;
int number;
Scanner in = new Scanner(System.in);
System.out.print("Enter a character : ");
c = in.next().charAt(0); // read character
System.out.print("Enter a number line :");
number = in.nextInt(); // reads number
displayRowofCharacters(c,number); // call method
displayRowofCharacters()
}
public static void displayRowofCharacters(char c, int count)
{
if(count >0) //recursion loops count > 0
{
System.out.print(c); //print the c
displayRowofCharacters(c,count-1); // call method
displayRowofCharacters() but count -1
}
else
{
return;
}
}
}
Output:

Write a JAVA program: Consider the method displayRowOfCharacters that displays any given character the specified number...
Use Java to answer the question (Occurrences of a specified character) Write a method that finds the number of occurrences of a special character in a string using the following header: public static int count (String str, char a) For example, count("Welcome", 'e') returns 2. Write a test program that prompts the user to enter a string followed by a character then displays the number of occurrences of the character in the string. In addition to the requirements described in...
Write a java program that demonstrates recursion. This program can be in a java GUI frame or as a console application. On this one it is up to you. (It would probably work better as a console program for this particular program.) The input for this program is a number of boxes. Ask the user for this with a textbox or a prompt on the command line. Demonstrate recursion with a function called LoadTruck() that takes a number of boxes...
Write a program that receives a character and displays its Unicode. using java please
I need java code for the following problem.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: o Write a method called cubeIt that accepts one integer parameter and returns the value raised to the third power as an integer. 2. Write a method called randomInRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. o Write a method called larger that accepts two double parameters and...
in Java
This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a character. Modify the given program to output a right triangle that instead uses the user-specified trianglechar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as % or* Each subsequent line will...
Write a Java application that displays the following output pattern: Thus, there are+signs everywhere except the diagonal, which has". "signs. There are no blank characters. Requirements and Restrictions: The number of lines and the number of characters per line, i.e. the size of the square pattern and line argument. For example, the size of the above square is 11 and it is specified through the following compile and execute commands: e >javac PrintPattern.java > java PrintPattern 11 Your program should...
Please write this in java
Write one static method to print each character in the
output. There should be methods to print: H, E, L, O,
(comma), W, R, D and (exclamation point). The method
to print H should be called printH() and the method to
print the comma should be called printComma(). Make
sure to separate characters with a new line in the method
(except the comma) as shown on right. Write a method called
printHelloWorld() to call the...
Write a full program that will accept any number of command line arguments and print them to the screen. Suppose your program is called Print.java. When the command java Print hello goodbye you is run, the output will be hello goodbye you Write a full program that will accept exactly three command line arguments that can be interpreted as integers, and will add them up. If there aren't exactly 3 command line arguments, print an error message and terminate the program....
Please write code in C++ and include all headers not bits/stdc: 17.10 (Occurrences of a specified character in a string) Write a recursive function that finds the number of occurrences of a specified letter in a string using the following function header. int count(const string& s, char a) For example, count("Welcome", 'e') returns 2. Write a test program that prompts the user to enter a string and a character, and displays the number of occurrences for the character in the...