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
Crank
3 years ago
6

Write a method called printRange that accepts two integers as arguments and prints the sequence of numbers between the two argum

ents, separated by spaces. Print an increasing sequence if the first argument is smaller than the second; otherwise, print a decreasing sequence. If the two numbers are the same, that number should be printed by itself. Here are some sample calls to printRange:printRange(2, 7);printRange(19, 11);printRange(5, 5);The output produced from these calls should be the following sequences of numbers:2 3 4 5 6 719 18 17 16 15 14 13 12 115Test the method using the following main program:import java.util.*; // for Scannerpublic class Lab4Q2 {public static void main(String[] args) {Scanner console = new Scanner(System.in);System.out.print("Enter a positive integer: ");int num1 = console.nextInt();System.out.print("\nEnter a second positive integer: ");int num2 = console.nextInt();System.out.println();printRange(num1, num2);}
Computers and Technology
1 answer:
Papessa [141]3 years ago
4 0

Answer:

import java.util.*;

// for Scanner

public class Lab4Q2{

     public static void main(String[] args){

           Scanner console = new Scanner(System.in);

           System.out.print("Enter a positive integer: ");

           int num1 = console.nextInt();

           System.out.print("\nEnter a second positive integer: ");

           int num2 = console.nextInt();

          System.out.println();

          printRange(num1, num2);

}

     public static void printRange(int a, int b){

           if(a == b){

               System.out.print(a);

}           else if (a < b){

                for(int i = a; i <= b; i++){

                     System.out.print(i + " ");

}

}

           else if (a > b){

                for(int i = a; i >= b; i--){

                    System.out.print(i + " ");

}

}

}

}

Explanation:

In the printRange method that is called from the main method; we pass the two parameters of numbers entered as 'a' and 'b'. First, we check if 'a' and 'b' are the same, then we output a single instance of the input.

Next, we check if the first input is less than the second input then we output in ascending order.

Lastly, we check if the first input is greater than the second input then we output in descending order.

You might be interested in
"Consideration of being digitally" literate Means to produce digital technology Participate in digital activities none of the ch
masha68 [24]

Answer:

Participate in digital activities.

Explanation:

Digital literacy is a concept that describes the ability of writing, messaging, designing graphics, socialisation etc, with or through a digital device platform.

It's principles are based on discipline like social sciences, computer literacy, visual literacy and many more.

A digital literate is an individual that can interact with digital platforms to write, design graphics, socialize, create videos and audio and creatr other types of digital documents.

8 0
3 years ago
This is not a feature provided by most GUIS.<br> icons<br> windows<br> forms<br> menus
Murrr4er [49]
Maybe menus I’m not sure but good luck
5 0
2 years ago
Read 2 more answers
Ano ang bunga ng pagsunod sa tamang konsiyensiya?
gladu [14]

Answer:

A.

Explanation:

mapalaganap ang kabutihan

8 0
2 years ago
Read 2 more answers
which endpoint application runs on an endpoint device that only detects an attack in an endpoint device? chqgg
WARRIOR [948]

A host-based intrusion detection system works similarly to a network-based intrusion detection system in that it can monitor and analyze both the internal workings of a computer system and the network packets on its network ports.

<h3>What is Host-Based IPS?</h3>
  • A host-based intrusion detection system works similarly to a network-based intrusion detection system in that it can monitor and analyze both the internal workings of a computer system and the network packets on its network ports.
  • The Host-based Intrusion Prevention System (HIPS) guards against malicious software and other activities that aim to harm your computer. HIPS uses sophisticated behavioral analysis in conjunction with network filtering's detection capabilities to keep track of active programs, files, and registry keys.
  • The integrated endpoint security system known as endpoint detection and response (EDR), also referred to as endpoint threat detection and response (ETDR), combines real-time continuous monitoring and gathering of endpoint data with rules-based automated reaction and analysis capabilities.

To learn more about Host-Based IPS refer to:

brainly.com/question/20490376

#SPJ4

5 0
1 year ago
The first mechanical computer design in by Charles Babbage was Called​
White raven [17]

Answer:

<h2>Analytical Engine</h2>

Explanation:

Analytical Engine, generally considered the first computer, designed and partly built by the English inventor Charles Babbage in the 19th century (he worked on it until his death in 1871).

7 0
3 years ago
Read 2 more answers
Other questions:
  • major m,ajorrr points helpppppppppppppppppppppppppppi have a question i hit a few buttons and now my computer is saying everythi
    11·2 answers
  • You have been contracted by a local school to evaluate their computer labs for security threats. They are most worried about the
    6·1 answer
  • We want to construct a memory with 256 bytes in capacity. Assume that each byte has a unique address. (a) How many address lines
    14·1 answer
  • Janelle is at the store and can't decide whether to buy steak for dinner or bring home pizza. To get a quick response from her p
    13·1 answer
  • In which of the following phases of filmmaking would a production team be focused on the
    10·2 answers
  • The identification of the technology management framework contain?
    6·1 answer
  • 1) SuperFetch is a memory-management technique that a) determines the type of RAM your system requires. b) makes the boot-up tim
    7·1 answer
  • KAPWING Video Editing Software allows you to use existing You Tube Videos in your design.
    8·1 answer
  • Which family does Ms word 2007 belongs to?​
    6·2 answers
  • Write a FOR loop that displays the following numbers exactly like this (you must use a loop):
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!