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
Kamila [148]
2 years ago
12

What does the following if statement do? if (num1 == Math.abs(num1))

Computers and Technology
1 answer:
Gennadij [26K]2 years ago
6 0

This statement checks if num1 is equal to the absolute value of num1

For instance,

num1 = 4 and the absolute value of num1 = 4. This would run the code inside the if statement but if num1 = -1 the absolute value of num1 = 1 and the if stamtent would be skipped because -1 does not equal 1

You might be interested in
Monster Collector
Lera25 [3.4K]

Answer:

In java:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 int monsternum, usernum;

 int count = 0;

 Random rand = new Random();

 String [] monsters = {"wild pikamoo","wild bulbaroar"};

 for(int i =0;i<2;i++){

     monsternum = rand.nextInt(5);  

     System.out.print("A "+monsters[i]+" appears! Guess a number between 1 and 5: ");

     usernum = input.nextInt();

     if(monsternum == usernum){      count++;      System.out.println("Congratulations, you caught a "+monsters[i]+"!");  }

 else{      System.out.println("You almost had it, but the monster escaped.");  }

 

 }

 System.out.println("There are no more monsters to encounter!");

 System.out.println("You caught "+count+" monsters of 2");

 if(count!=2){      System.out.print("Keep training to be the very best!");  }

 else{      System.out.print("You're the monster collector master!");  }

}

}

Explanation:

This declares monster and user number as integers

 int monsternum, usernum;

Initialize count to 0

 int count = 0;

Call the random object

 Random rand = new Random();

Create a string array to save the monster names

 String [] monsters = {"wild pikamoo","wild bulbaroar"};

Iterate for the 2 monsters

 for(int i =0;i<2;i++){

Generate a monster number

     monsternum = rand.nextInt(5);  

Prompt the user to take a guess

     System.out.print("A "+monsters[i]+" appears! Guess a number between 1 and 5: ");

Get user guess

     usernum = input.nextInt();

If monster number and user guess are equal, congratulate the user and increase count by 1

<em>      if(monsternum == usernum){      count++;      System.out.println("Congratulations, you caught a "+monsters[i]+"!");  } </em>

If otherwise, prompt the user to keep trying

<em>  else{      System.out.println("You almost had it, but the monster escaped.");  }  </em>

<em>  } </em>

Print no monsters again

 System.out.println("There are no more monsters to encounter!");

Print number of monsters caught

 System.out.println("You caught "+count+" monsters of 2");

Print user score

<em>  if(count!=2){      System.out.print("Keep training to be the very best!");  } </em>

<em>  else{      System.out.print("You're the monster collector master!");  } </em>

5 0
3 years ago
1. What does MS-DOS use for input?
Ket [755]

1. The answer is Command-line base

MS-DOS is a single user, single tasking OS that use a command line interface. MS –DOS is the perfect example of a command line interface. CLI is a text based interface used by operating systems and software and performs particular tasks by entering commands. Unlike the GUI (Graphical User Interface), the CLI uses a very easy mechanism which is not user friendly.  

2. The answer is carry electrical current

Transistors are semiconductor devices used to control the flow of electricity in circuits. They contain three layers of silicon that are used to amplify or switch electric currents. They are very fundamental in modern electronic devices and are considered one of the greatest inventions in modern history. In small quantities, transistors are used to make simple switches and digital logic. In huge quantities, transistors are interconnected and combined into small chips that create complex ICs, computer memories, and processors.

3. The answer is True

A peripheral device such as a keyboard, a mouse, or a printer is a hardware input or output device that gives the computer additional functionalities and serve as an auxiliary computer device. They are commonly known as I/O devices because they provide input and output information for the computer.

4. The answer is A: Interacts with or sends data to the computer

A peripheral device as mentioned above is used to input information into and get it out of the computer. In addition, an input device sends data, information, or instructions to the computer. Examples of input devices include, keyboard, mouse, graphics tablet, game controller, read only memory, and many more.

5. The answer is doc .

Doc file extension is the general default binary and XML-based format for Word 97 all the way to Word 2019. This file extension can contain formatted texts, tables, images, page formatting, and graphs. Depending on the versions of the Microsoft Word, the standards for the DOC extension change slightly from .doc to .docx


5 0
3 years ago
Ally made the net below to find the surface area of a box she was designing. The box measures 12 centimeters long by 9 centimete
jarptica [38.1K]

The area of the box is 972.

7 0
3 years ago
Sandy's keyboard is not inputting data into her computer which key should she press to verify it is connected to her computer...
Ksivusya [100]

Answer:

Windows key,capslock key for verify connectivity

Explanation:

Sandy's can verify whether her keyboard is working or not by pressing the windows key. Caps Lock and Num lock key will turn on the light on keyboard and she shall see whether her keyboard is functioning or not. This method is being used everywhere to verify the keyboard connectivity.The light function can also be checked by using Caps Lock or Num lock key as well. Some keyboard offers the in built light, which can be turned on by pressing Alt+Space bar.

5 0
3 years ago
Methods used to change variables are called ______. equals accessors toString void mutators
Sindrei [870]
Look this up on Quizlet. Besure to check the question and the answers carefully by using "define + the vocabulary word" you think answers the question.

Here is the exact site: just copy it and search and click...

<span>AP Comp Sci Chapter 5</span>
6 0
2 years ago
Other questions:
  • Anna wants to open the Run dialog box to run her program file. Which keys should she press to open the Run dialog box?
    14·1 answer
  • Help me Please?!! I will put you as brainliest.<br>I hope I spelled that right.
    5·2 answers
  • What should a career plan include?
    7·1 answer
  • A signal has a spectrum from 0 to 145 Hz, as shown below. It is sampled at a rate of 295 Hz. Find the region of the baseband spe
    5·2 answers
  • A chef writing up her famed recipe for beef stew realizes she has switched parsley and oregano everywhere in the recipe. The che
    13·1 answer
  • Sierra owns a small business and handles many responsibilities, from logistics to marketing. She's seen a lot of success with Go
    11·1 answer
  • The model for Diminishing Marginal Utility is ______ in nature.
    12·1 answer
  • I like to troll what about you
    10·1 answer
  • Which part of the computer is responsible for managing memory allocation for all applications
    12·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!