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
AleksAgata [21]
3 years ago
8

(Display four patterns using loops) Ask the user to enter an integer to

Computers and Technology
1 answer:
fomenos3 years ago
4 0

Answer:

Hi There was small mistake. It is working fine for me. When you run from command line - use LoopPattern, not looppatern

import java.util.Scanner;

public class Looppattern {

  public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);

      System.out.println("Enter how man levels you need: ");

      int levels = sc.nextInt();

      System.out.println("\n---------------Pattern A-----------------\n");

      for (int p = 1; p <= levels; p++) {

          for (int k = 1; k <= p; k++) { // increasing each level printing

              System.out.print(k);

          }

          System.out.println();

      }

      System.out.println("\n---------------Pattern B-----------------\n");

      int r = levels;

      for (int p = 1; p <= levels; p++) {

          for (int k = 1; k <= r; k++) {

              System.out.print(k);

          }

          r--; // decreasing levels

          System.out.println();

      }

      System.out.println("\n---------------Pattern C-----------------\n");

      for (int p = 1; p <= levels; p++) { // here incresing

          for (int k = p; k > 0; k--) { // and here decreasing pattern to

                                          // achieve our required pattern

              System.out.print(k);

          }

          System.out.println();

      }

      System.out.println("\n---------------Pattern D-----------------\n");

      r = levels;

      for (int p = 1; p <= levels; p++) {

          for (int k = 1; k <= r; k++) {

              System.out.print(k);

          }

          r--; // decreasing levels

          System.out.println();

      }

  }

}

Explanation:

You might be interested in
Create and test a user-defined function named ufnFullName that combines the values of the two parameters named FirstName and Las
8090 [49]

Answer:

   public static String ufnFullName(String Fname, String Lname){

       String FullName = Fname+" "+Lname;

       return  FullName;

   }

Explanation:

Using Java programming language, the function is created to accept two String parameters (Fname and Lname)

These are concatenated into a new String FullName and returned by the function

See below a complete code that prompts users to enter value for first and last names then calls this method to display the full name

<em>import java.util.Scanner;</em>

<em>public class FullName {</em>

<em>    public static void main(String[] args) {</em>

<em>        System.out.println("Enter First Name");</em>

<em>        Scanner in = new Scanner(System.in);</em>

<em>        String Fname = in.next();</em>

<em>        System.out.println("Enter Last Name");</em>

<em>        String Lname = in.next();</em>

<em />

<em>        System.out.println("Your Full Name is "+ufnFullName(Fname,Lname));</em>

<em>    }</em>

<em>    public static String ufnFullName(String Fname, String Lname){</em>

<em>        String FullName = Fname+" "+Lname;</em>

<em>        return  FullName;</em>

<em>    }</em>

<em>}</em>

8 0
3 years ago
What two different passwords can be set to lock down a computer from unauthorized access?
Shalnov [3]

The two different passwords you can use to lock down a computer from unauthorized access would be,

1. The Supervisor password

2. The User Password.

- Mabel <3

3 0
3 years ago
True or False? Most operating systems allow the user to specify a set of paths that are searched in a specific order to help res
inessss [21]

Answer:

The correct answer to the following question will be "True".

Explanation:

The "kernel" as shown at the core of your OS would be the central machine program. The program facilitates the essential functions of a computer processor, including coordinating activities, executing programs, and managing devices. This allows users to define a series of directions to try to resolve the connections to running program files in an order of preference.

So, the given statement is true.

4 0
3 years ago
You just received a message from the internet which was encrypted with asymmetric encryption. what do you need to do to read the
Bezzdna [24]
Assuming the data was encrypted with YOUR public key, you'll need YOUR private key to decrypt it. That's answer e.

a and b are not solutions by themselves, of course you need to use the decryption algorithm, but a key goes with it.

c would be about symmetric encryption, but this is asymmetric, so different keys are used for encryption and decryption

d is possible, but it would mean anyone can decrypt it (after all the key is public), so then there's no point in encrypting it in the first place.

So e is the only logical answer.
5 0
3 years ago
Which of the following is true about occupations within the STEM fields? Many occupations use mathematics, even if it is not the
Kazeer [188]

Answer:

Many occupations use mathematics, even if it is not the primary focus of a given job.

Explanation:

Think about software developers, they develop apps, websites, and other things, but they also use math in the process. Scientists use statistics. Mechanics use math to make sure their measurements are right. Therefore, I think your best bet would be

A. Many occupations use mathematics, even if it not the primary focus of a given job.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Write a program that responds to a positive integer passed on the command line with the number of bits needed to express that nu
    10·1 answer
  • When security issues are a special concern, companies want to take extra steps to make sure that transmissions can’t be intercep
    7·1 answer
  • Each device attached to your computer comes with a special program called a(n ________ that enables the device and operating sys
    15·1 answer
  • How can a student manage time and stress for better results in school? Check all that apply. by taking breaks while studying by
    8·2 answers
  • A garments manufacturing company buys various types of natural and synthetic materials to produce clothes. Which material is a s
    6·2 answers
  • 4.2 lesson practice last one plzs help
    5·2 answers
  • Drag each tile to the correct box.
    8·1 answer
  • How do you create a CA file? short answer
    8·1 answer
  • When delivering digital technologies to clients, what is a best practice to make those solutions sustainable?
    10·1 answer
  • imagine that you are explaining the art of visual comparison to a group of photography students. You are mentoring. What do you
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!