Question

In: Computer Science

In java coding, write a program that will print out a representation of a “W” using...

In java coding, write a program that will print out a representation of a “W” using a character that a user provides.

Solutions

Expert Solution

ANSWER: Here I am giving you the code and output please like it or comment your problem.

CODE:

import java.util.Scanner;

public class Wpattern {

  
       private static void YourCharacter(int count, char ch)
       {
           for (int i = 0; i < count; ++i)
       System.out.print(ch);
       }
      
      
       private static void betweenSpaces(int count)
       {
       for (int i = 0; i < count; ++i)
       System.out.print(" ");
       }
         
       public static void main(String[] args)
       {
           int n;
           Scanner scan=new Scanner(System.in);
      
       // That is your number of rows
       System.out.print("Enter the number for pattern : ");
       n=scan.nextInt();
       System.out.println("Enter your special character: ");
       char ch=scan.next().charAt(0);
      
       for (int i = 0; i < n; ++i)
       {
           YourCharacter(i + 1,ch);
       betweenSpaces(n - i - 1);
       YourCharacter(n - i + 1, ch);
       YourCharacter(2 * i, ch);
       YourCharacter(n - i,ch);
       betweenSpaces(n - i - 1);
       YourCharacter(i + 1, ch);
         
       System.out.println();
       }
       }

   }


output:


Related Solutions

Write a program that will print out “W” using a character that a user provides. use...
Write a program that will print out “W” using a character that a user provides. use for loop statement. in java please
Write a complete Java program to print out the name bob
Write a complete Java program to print out the name bob
Write a Java program that accepts a sequence of commands and print out the number of...
Write a Java program that accepts a sequence of commands and print out the number of successful insertions, the number of successful deletions, the number of successful searches (through the “find” command), the number of items remaining in the list after executing all commands and the final contents of the list. Three commands that will be taken as inputs are “insert”, “delete” and “find”. Input Line 1: The number of transactions m on the list, where 1  m 200. Line 2...
Write java program that will ask for the user for 2 input lines and print out...
Write java program that will ask for the user for 2 input lines and print out all words that occur 1 or more times on both lines (case sensitive). Write this without arrays and method. Here is a sample run: <Output> Enter two lines to process. The quick brown fox jumps over a lazy dog The fox hound outruns the lazy dog The words that occur on both lines are: The fox lazy dog
. Write a program to print * in the following order using 2d array in java...
. Write a program to print * in the following order using 2d array in java                                              *             *             *             *             *                                              *             *             *             *                                              *             *             *                                              *             *                                                          *
Write a Java program using jGRASP directions are as follows: Uses a while loop to print...
Write a Java program using jGRASP directions are as follows: Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider...
I need it in java. Write a program that will print if n numbers that the...
I need it in java. Write a program that will print if n numbers that the user will input are or not within a range of numbers. For that, your program needs to ask first for an integer number called N that will represent the number of times that will ask for other integer numbers. Right after, it should ask for two numbers that will represent the Min and Max for a range. Lastly. it will iterate N number times...
Write a java program that will take a line of input and go through and print...
Write a java program that will take a line of input and go through and print out that line again with all the word numbers swapped with their corresponding numeric representations (only deal with numbers from one to nine). Sample runs might look like this: Please enter a line of input to process: My four Grandparents had five grandchildren My 4 grandparents had 5 grandchildren without array and methods.
Write a program in Java that initializes an array with ten random integers and then print...
Write a program in Java that initializes an array with ten random integers and then print three lines of output, containing: Every element at an odd index Every odd element All elements in reverse order   The program should use three different methods to implement the functionalities above. Call the primary source file ArrayManipulator.java
Write a program that will take a line of input and go through and print out...
Write a program that will take a line of input and go through and print out that line again with all the uppercase letters swapped with the lowercase letters. JAVA Using printf
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT