Question

Problem #5: This one is a challenge!! Write a program that will print out a representation...

Problem #5: This one is a challenge!! Write a program that will print out a representation of the University of Washington “W” using a character that a user provides.

Homework Answers

Answer #1

ANSWER:-

GIVEN THAT:-

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:-

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
problem 1 Write a program that asks the user for an integer and then prints out...
problem 1 Write a program that asks the user for an integer and then prints out all its factors. For example, when the user enters 84, the program should print 2 2 3 7 Validate the input to make sure that it is not a character or a string using do loop. in c plus plus
Problem: Write a C program that simulates a die with six faces. The program is rolling...
Problem: Write a C program that simulates a die with six faces. The program is rolling the die for the user, but the user needs to specify how many times the die needs to be rolled. Have the program print out how many times a certain face came up, along with the percentage out of 100%.
Write a MIPS assembly program that asks the user first for a string, then for a...
Write a MIPS assembly program that asks the user first for a string, then for a character. The program should search the string for the character and print out the number of times the character appears in the string. Restrictions can be used, just be sure to list them. You must allocate space in the .data segment of your program for the user string.
IN JAVA 1. Write up a small program that accepts two integers from the user. Print...
IN JAVA 1. Write up a small program that accepts two integers from the user. Print which of the two values is bigger. If they are the same, print that they are the same. 2. Write a method that accepts three doubles. Calculate and return the average of the three passed double values. 3. Write up a method that accepts a score between 0-10. Print out a message according to the following table. You ay personally decide the boundaries. i.e.,...
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other my name's Aya amro
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other The first letter A and the last letter O
3) Write a program to print out a random number from 1..100. USING ASSEMBLY LANGUAGE
3) Write a program to print out a random number from 1..100. USING ASSEMBLY LANGUAGE
In Python: Problem 4. Write a program [call it minmax.py] that accepts three integers in the...
In Python: Problem 4. Write a program [call it minmax.py] that accepts three integers in the range [0-100] as input from the user. Your program should then determine and print the smallest and largest integers in the values entered by the user using comparison operators *not* using predefined min or max Python functions. For instance: If the user input is: 36 5 99 your program should give as output: min = 5 max = 99 If the user input is:...
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
Analyze the following programs and write down the output of the program. Please print every character...
Analyze the following programs and write down the output of the program. Please print every character (including whitespace character) clearly!       # include <iostream> using namespace std;   int fun( int a ) {       int b = a * 2;       return b;   }   int main()   {       int y = 5;       cout << fun(y) << endl;       cout << fun(-- y) << endl;       cout << fun(y--) << endl;       cout << y <<endl;           return 0;   }
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT