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
kogti [31]
3 years ago
6

Create a conditional expression that evaluates to string "negative" if userVal is less than 0, and "non-negative" otherwise. Ex:

If userVal is -9, output is: -9 is negative.
Engineering
1 answer:
oksian1 [2.3K]3 years ago
5 0

Answer:

(userVal < 0) ? "negative" : "non-negative" ;

Explanation:

The above code has been written using Java's ternary operator (? : ).

Java uses this operator to write conditional expressions that are similar to the regular if ... else statements.

This expression has three parts,

i. the conditional statement: this is the expression before the ? mark. In this case, (userVal < 0). This expression contains the condition to be tested for and it returns true or false.

ii. the second part is the statement after the ? mark. In this case, "negative". This expression will be executed if the conditional statement returns true.

iii. the third part is the statement after the : mark. In this case, "non-negative". This expression will be executed if the conditional statement returns false.

So in this case, if userVal < 0, the string "negative" will be evaluated. Otherwise, "non-negative".

You might be interested in
Consider a fan located in a 3 ft by 3 ft square duct. Velocities at various points at the outlet are measured, and the average f
natulia [17]

Answer:

minimum electric power consumption of the fan motor is 0.1437 Btu/s

Explanation:

given data

area = 3 ft by 3 ft

air density = 0.075 lbm/ft³

to find out

minimum electric power consumption of the fan motor

solution

we know that energy balance equation that is express as

E in - E out  = \frac{dE \ system}{dt}    ......................1

and at steady state  \frac{dE \ system}{dt} = 0

so we can say from equation 1

E in = E out

so

minimum power required is

E in = W = m \frac{V^2}{2} = \rho A V \frac{V^2}{2}  

put here value

E in =  \rho A V \frac{V^2}{2}  

E in =  0.075 *3*3* 22 \frac{22^2}{2}  

E in = 0.1437 Btu/s

minimum electric power consumption of the fan motor is 0.1437 Btu/s

5 0
3 years ago
In which situation is a are food service workers not required to wash their hands?
Margarita [4]

Answer:

when wearing gloves?

Explanation:

?

or when off duty

3 0
3 years ago
Read 2 more answers
Given a matrix, clockwise-rotate elements in it. Please add code to problem3.cpp and the makefile. Use the code in p3 to test yo
rusak2 [61]

Answer:

/* C Program to rotate matrix by 90 degrees */

#include<stdio.h>

int main()

{

int matrix[100][100];

int m,n,i,j;

printf("Enter row and columns of matrix: ");

scanf("%d%d",&m,&n);

 

/* Enter m*n array elements */

printf("Enter matrix elements: \n");

for(i=0;i<m;i++)

{

 for(j=0;j<n;j++)

 {

  scanf("%d",&matrix[i][j]);

 }

}

 

/* matrix after the 90 degrees rotation */

printf("Matrix after 90 degrees roration \n");

for(i=0;i<n;i++)

{

 for(j=m-1;j>=0;j--)

 {

  printf("%d  ",matrix[j][i]);

 }

 printf("\n");

}

 

return 0;

 

}

5 0
4 years ago
A transmission line with an imperfect dielectric is connected to an ideal time-invariant voltage generator. The other end of the
kari74 [83]

Answer and Explanation:

O decreases linearly with the distance from the generator

4 0
3 years ago
A 10.2 mm diameter steel circular rod is subjected to a tensile load that reduces its cross- sectional area to 52.7 mm^2. Determ
VMariaS [17]

Answer:

The percentage ductility is 35.5%.

Explanation:

Ductility is the ability of being deform under applied load. Ductility can measure by percentage elongation and percentage reduction in area. Here, percentage reduction in area method is taken to measure the ductility.

Step1

Given:

Diameter of shaft is 10.2 mm.

Final area of the shaft is 52.7 mm².

Calculation:

Step2

Initial area is calculated as follows:

A=\frac{\pi d^{2}}{4}

A=\frac{\pi\times(10.2)^{2}}{4}

A = 81.713 mm².

Step3

Percentage ductility is calculated as follows:

D=\frac{A_{i}-A_{f}}{A_{i}}\times100

D=\frac{81.713-52.7}{81.713}\times100

D = 35.5%.

Thus, the percentage ductility is 35.5%.

5 0
3 years ago
Other questions:
  • (1) 1. (15 points/ 3 points each) (a) Draw the binary search tree that is created if the following numbers are inserted in the t
    9·1 answer
  • An air conditioner removes heat steadily from a house at a rate of 750 kJ/min while drawing electric power at a rate of 6 kW. De
    5·1 answer
  • A preheater involves the use of condensing steam at 100o C on the inside of a bank of tubes to heat air that enters at I atm and
    14·1 answer
  • A 100-mm-diameter cast Iron shaft is acted upon by a 10 kN.m bending moment, a 8 kN.m torque, and a 150 kN axial force simultane
    9·1 answer
  • Implement a program that manages shapes. Implement a class named Shape with a method area() which returns the double value 0.0.
    8·1 answer
  • Okay bro let’s go man yes yes
    9·2 answers
  • The hot-wire anemometer.' A hot-wire anemome ter is essentially a fine wire, usually made of platinum,which is heated electrical
    6·1 answer
  • Raw materials used of silicone rubber
    6·2 answers
  • 1. A cylindrical casting is 0.3 m in diameter and 0.5 m in length. Another casting has the same metal is rectangular in cross-se
    11·1 answer
  • What is resonance as in ultrasound waves formation using magnetostriction method​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!