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%.
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
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....
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:...
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;   }
This program is for kindergartners to practice knowledge on numbers divisible by 5. Write a code...
This program is for kindergartners to practice knowledge on numbers divisible by 5. Write a code using a while loop, which keeps asking the user to enter an number divisible by 5. The program(i.e the while loop) terminates when the user enters a number divisible by 5, but keeps running if the user fails to enter a number divisible by 5. Also print appropriate message after each failed try. When successful, tell the user how many attempts were needed for...
Provide Python code that does the following: 4) Write a program that asks the user to...
Provide Python code that does the following: 4) Write a program that asks the user to enter a 9 character password. Test to see if it is a valid password. The validity test is a) they enter exactly 9 characters AND b) that every 3rd character, starting with the 1st character is the letter z. If it is valid print out the message “valid password” otherwise print the message “invalid password”. Sample output. Please enter a password: zaazbbz12 valid password...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT