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
Harrizon [31]
3 years ago
14

What order? (function templates) Define a generic function called CheckOrder() that checks if four items are in ascending, neith

er, or descending order. The function should return -1 if the items are in ascending order, 0 if the items are unordered, and 1 if the items are in descending order. The program reads four items from input and outputs if the items are ordered. The items can be different types, including integers, strings, characters, or doubles. Ex. If the input is:
Computers and Technology
1 answer:
vlabodo [156]3 years ago
8 0

Answer:

Explanation:

The following code was written in Java and creates the generic class to allow you to compare any type of data structure. Three different test cases were used using both integers and strings. The first is an ascending list of integers, the second is a descending list of integers, and the third is an unordered list of strings. The output can be seen in the attached image below.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Order: " + checkOrder(10, 22, 51, 53));

       System.out.println("Order: " + checkOrder(55, 44, 33, 22));

       System.out.println("Order: " + checkOrder("John", " Gabriel", "Daniela", "Zendaya"));

   }

   public static <E extends Comparable<E>> int checkOrder(E var1, E var2, E var3, E var4) {

       E prevVar = var1;

       if (var2.compareTo(prevVar) > 0) {

           prevVar = var2;

       } else {

           if (var3.compareTo(prevVar) < 0) {

               prevVar = var3;

           } else {

               return 0;

           }

           if (var4.compareTo(prevVar) < 0) {

               return 1;

           }  else {

               return 0;

           }

       }

       if (var3.compareTo(prevVar) > 0) {

           prevVar = var3;

       }

       if (var4.compareTo(prevVar) > 0) {

           return -1;

       }

       return 0;

   }

}

You might be interested in
Which business application uses location information to provide a service and is designed to give mobile users instant access to
statuscvo [17]

Answer:

The correct answer to the following question will be "Location-based services".

Explanation:

Location-based services are resources that are delivered via a cell phone to take into consideration the geographical location of just the user. It usually include entertainment or data.

  • This uses the technology of GPS from a smartphone to detect the location or the position of an individual if that individual has expressed a preference-in to enable the service to do just that.
  • The app will classify its search down to a physical address during a smartphone user chooses-in, without any need for automatic input of the data.

Therefore, it's the right answer.

3 0
3 years ago
What does the shell of a operating system do?
gulaghasi [49]

The shell of an operating system is the programming that interprets the commands and actions of the user of the system.

6 0
3 years ago
In a List of Positive Integers, Set MINIMUM to 1. For each number X in the list L, compare it to MINIMUM. If X is smaller, set M
Dvinal [7]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The given problem scenario is:

In a List of Positive Integers, Set MINIMUM to 1. For each number X in the list L, compare it to MINIMUM. If X is smaller, set MINIMUM to X.

The answer to question A is: this algorithm will not run because:

If you a list of a positive number and you have already set it MINIMUM to 1, the comparison result with MINIMUM will not obtain. For example, lets suppose a list of numbers L. L={1,2,3,1,1,5,4,3,2}. You have already set the Minimum to 1. When you compare each number X in the list, if X >MINIMUM, then set MINIMUM to X.  

This will not work, because there are positive numbers in the list and the minimum positive number is 1. So the algorithm, will not execute the if-part.

In short, the pseudo-code of this problem is given below:

<em>L={list of positive number e.g. 1,2,3,.......Xn}</em>

<em>MINIMUM=1</em>

<em>foreach ( X in L)</em>

<em>{</em>

<em>(if X<MINIMUM)</em>

<em>    { </em>

<em>        MINIMUM=X</em>

<em>    }</em>

<em>}</em>

The answer to question B is X will not be replaced because X  replaced with MINIMUM only when if-part of this algorithm get executed. However, it is noted that X will not replace any value, if if-part will get executed, the Variable MINIMUM will get replaced with any value.

4 0
3 years ago
Why would it be beneficial to preview a page before printing?
enyata [817]
To make sure it looks how you want it to look, or to make sure all the info is correct and we're it should be.
4 0
3 years ago
Computer ForensicsThere are many differences between public-sector and private-sector computer investigations. What do you see a
elena55 [62]

Answer:

For a private computer investigation into cyber crime the private sector  should complete all its courses and must be certified by the relevant authorities and must also be an expert in the computer investigations. while

Public computer investigations has more aspects that involves non-certified personnel's

The private-sector computer investigations are used mostly on all the cyber crimes and hacking and loss of business data.while public-sector computer investigations are used on crimes like rapes, accidents and murders crimes

Explanation:

Computer forensics are used to resolve crimes like cyber crime, hacking, malfunctions and data interrupts.

Before a private computer investigations which is into cyber crime investigation can continue, the private sector  should complete all its courses and must be certified by the relevant authorities and must also be an expert in the computer investigations. while

Public computer investigations has more aspects that involves non-certified personnel's and the personnel's are not necessarily supposed to complete the courses

The private-sector computer investigations are used mostly on all the cyber crimes and hacking and loss of business data.while public-sector computer investigations are used on crimes like rapes, accidents and murders crimes

5 0
4 years ago
Other questions:
  • Spencer is a recent graduate who finds a dream car that costs $45,000. Even better, there's a 0% APR for 36 months offer from th
    13·1 answer
  • Select the correct answer.
    7·1 answer
  • Write an algorithm that receives 500 numbers from the user and prints out the maximum of the numbers.
    9·1 answer
  • Send the memes whoever is the best will get that crown thing lol
    10·2 answers
  • Which are guidlines for using themes? Check all that apply
    13·1 answer
  • Software que busca, detecta y elimina malware tipo espía; puede instalarse en la computadora de manera aislada o en conjunto con
    11·1 answer
  • The InfoBar is located below the ribbon and on top of a message. It is used for which purposes? Check all that apply. showing th
    9·2 answers
  • Por favor definir que es un pseudocódigo y que es un diagrama de flujo.
    13·2 answers
  • What is one similarity between low-and high-level programming languages? (5 points)
    14·1 answer
  • Write a function named swapFrontBack that takes as input a vector of integers. The function should swap the first element in the
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!