answer.
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
leva [86]
2 years ago
10

In Java please:Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) Syste

m.out.println("Positive."); else System.out.println("Non-positive, converting to 1."); userNum = 1; System.out.println("Final: " + userNum);
Computers and Technology
1 answer:
iren2701 [21]2 years ago
8 0

Answer:

import java.util.Scanner;

public class Solution {

   public static void main(String args[]) {

       Scanner scan = new Scanner(System.in);

       int userNum = scan.nextInt();

       if (userNum > 0) {

           System.out.println("Positive.");

           

       } else {

           System.out.println("Non-positive, converting to 1.");

           userNum = 1;

           System.out.println("Final: " + userNum);

           

       }

   }

}

Explanation:

There was no error found when the code was run. The code segment was just added to a main method and it runs successfully.

Based on the full code above;

The first line import the Scanner class which allow the program to receive user input. Then the class was defined as Solution. Then the main method was defined. Inside the main method, we created a scanner object scan which receive the input via keyboard. The user input is assigned to the variable userNum. Then the if-conditional statement is executed; if userNum is greater than 0, "Positive" is output. Else userNum is converted to 1 and outputted to the screen.

You might be interested in
Suppose a linked list of 20 nodes. The middle node has a data –250. Write the pseudocode to replace the middle node of the linke
dexar [7]

Answer:

The middle node has a data –250. ... Write The Pseudocode To Replace The Middle Node Of The Linked List With ... Assume That The List's Head Pointer Is Called Head_ptr And The Data For The New Node Is Called Entry ... Assume that the list's head pointer is called head_ptr and the data for the new node is called entry ...

Explanation:

4 0
2 years ago
Read 2 more answers
There are many different types of hardware devices, different manufacturers, and countless configuration possibilities. Explain
erik [133]

Because, they are all required to configure to it to be recognized by an operating system.

Explanation:

It is the Operating System Software that instructs the hardware and puts them together to work well. When the manufacturer does not configure the device to be recognized by an operating system, then it will not work with other components.

Example.

If an Apple machine's sound card is being put in an HP machine which uses Microsoft designed operating system, won't work due to the operating system that the sound card has been designed for.

6 0
2 years ago
American company Software Unlimited is planning to expand its operations to the Bangor Republic where the group is the primary u
FinnZ [79.3K]

Answer:E. Employees will achieve close cooperation with others.

Explanation: Employees will close cooperation with others as a result of the expansion of the company to the Bangor Republic where the group is the primary unit of social organisation, When a company expands to new locations it boosts employment morale and corporation as they find it as a form of expansion and overall good of the employees and their employer, most of expand as a result of favourable economic climates.

7 0
2 years ago
The code selection above is taken from the Color Sleuth activity you just completed. This selection would count as an abstractio
Vinvika [58]

Answer:

b

Explanation:

4 0
2 years ago
Which of the following meanings can a $ character assume within a regular expression? (can have more than 1 answer)
denis-greek [22]

Answer:

a. A literal dollar sign .

b. Shell variable syntax.

c. End-of-line anchor for pattern matching.

Explanation:

There are three answers to this question among the given options.

When a regular expression is quoted single, the $ character can act in one of two ways. end of line anchor for pattern matching.Elsewhere it acts as a literal dollar sign.

When a double quoted regular expression is there, the $ character is treated as a shell variable syntax.

7 0
2 years ago
Other questions:
  • In an ethernet network, the signal that is sent to indicate a signal collision is called a ________ signal.
    7·1 answer
  • Lance is at a bus station. His friend is using the ATM machine to withdraw some money. Lance notices a stranger deceptively watc
    6·2 answers
  • Which of the following represents the bus topology? Multiple Choice All devices are connected to a central device, called a hub.
    8·1 answer
  • Which is true of case-based reasoning (CBR)?
    6·1 answer
  • You're the sole IT employee at your company. Most of the computers in your fleet are Windows machines. Your boss wants you to se
    11·1 answer
  • Nicole wants to create a database to collect information about videos in her video rental store. She would like to use the datab
    9·1 answer
  • Gwen recently purchased a new video card, and after she installed it, she realized she did not have the correct connections and
    6·1 answer
  • ________ is a free online service that enables a user to contact a cell phone number to hear who answers the telephone without i
    5·1 answer
  • What types of messages flow across an SDN controller’s northbound and southbound APIs? Who is the recipient of these messages se
    15·1 answer
  • python (Business: check ISBN-10) An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10. T
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!