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
leva [86]
4 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]4 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
Refer to the exhibit. The web servers WS_1 and WS_2 need to be accessed by external and internal users. For security reasons, th
BigorU [14]

Answer:

c.Ports Fa3/1 and Fa3/2 on DSW1 will be defined as secondary VLAN isolated ports. Ports Fa3/34 and Fa3/35 will be defined as primary VLAN promiscuous ports.

Explanation:

Primary VLANs which can only be reached by using promiscuous port, comprises of the gateway and isolated VLANs for users to get out of a network.

The isolated ports can only communicate i.e send and receive data with the promiscuous ports; Fa3/34 and Fa3/35.

Also, WS_1 and WS_2 can neither send nor receive data with the data server, thus we isolate them.

3 0
4 years ago
How can a user view the options for Junk E-mail?
alexdok [17]
B. by right clicking all messages in the junk email folder
8 0
3 years ago
Read 2 more answers
Sample answers of What assets were targeted Stuxnet and the team behind the worm?
Damm [24]
The assets were programmable logic controllers (PLCs).  Which controlled systems like prison doors and centrifuges for separating nuclear material. 

The "who" is still debated.  Credit (if you use that word) is given to the Equation Group.  But that is still hotly debated as there seems to be a political agenda with the attack and many still believe this was nation-state sponsored.  I can be easy to leave digital fingerprints behind to make it seem like a known hacking team.
8 0
4 years ago
When was third battle of Panipat fought​
enyata [817]

Answer:

January 14, 1761

Explanation:

6 0
3 years ago
It's best to use assertive speech when you<br> I want to show respect. *<br> True<br> False
mestny [16]

Answer:

True

Explanation:

Hope this helps :)

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which socket type is soldered to the motherboard, along with the cpu?
    6·1 answer
  • Which statement is used to create a file object that will append data to an existing file? BufferedWriter salesdata =
    9·2 answers
  • Whoevr answers this will be marked brainliest
    12·1 answer
  • What important Apple computer (with a GUI OS) was introduced in 1984? Apple I?
    13·1 answer
  • Which part of the os provides users and applications with an interface to manipulate files?
    8·1 answer
  • How does a project manager evaluate the scope of a project?
    14·2 answers
  • You want to substitute one word with another throughout your document. What tool(s) should you use?
    9·1 answer
  • Will has been asked to recommend a protocol for his company to use for a VPN connection to the cloud service provider that his c
    6·1 answer
  • Management is as old as human civilization. justify this statement​
    7·1 answer
  • Identify the type of software that should be in main memory in order to use the keyboard? *
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!