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
nlexa [21]
2 years ago
10

Assuming that the valid cost should be between 100 and 200, does the following code snippet test this condition correctly?

Computers and Technology
1 answer:
schepotkina [342]2 years ago
8 0

Answer:

  • No, Only the value between 100 and 200 can not test the code correctly.
  • This code snippet ensures that the cost value is between 100 and 200.

Explanation:

  • The above code has three condition test- if, else-if and else.
  • The first condition is true for the value which is a minimum of 100.
  • The else if condition is true for the value which is maximum from 200.
  • Then the else condition is used when the if and else if condition is false.
  • when the user gives the value between 100 and 200 then it will test that the value lies between 100 or 200.
  • To test the whole scenario there must be one value is less than 100 and greater than 200.
You might be interested in
Seneca has just applied conditional formatting and realizes that she has made a mistake. Which action should she take to fix the
erastova [34]

If Seneca has not done anything since the conditional formatting she can undo what her last action was. This is done by either pressing control+Z or by clicking on the undo icon.

If other actions have been done, there are a few more steps that need to be taken in order to clear the formatting. They are:

1. Select the cell or cells whose formatting you want to delete.

2. Display the Home tab of the ribbon.

3. In the Editing group, click Clear | Clear Formats.

8 0
2 years ago
Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative value
lozanna [386]

The code for the program described in question:

import java.util.Scanner;

public class Test {

   public static void main(String[] args) {

       double number;

       double squareRootOfNumber;

       String userInput = null;

       Scanner scanner = new Scanner(System.in);

       System.out.println("Enter the number: ");

       userInput = scanner.next();

       number = Double.parseDouble(userInput);

       squareRootOfNumber = Math.sqrt(number);

       if (number < 0) {

           throw new ArithmeticException("Can't take square root of negative number");

       }

       System.out.format("Square root of number entered is %.2f %n", squareRootOfNumber);

   }

}

The output of the program will be:

Enter the number:

-90

Exception in thread "main" java.lang.ArithmeticException: Can't take square root of negative number at com.brainly.ans.Test.main(Test.java:18)

Explanation:

Function from standard Java library <em>java.lang.Math.sqrt</em> will <em>not throw</em> an <em>ArithmeticException</em> even its argument is negative so there is no reason to surround your code try/catch block.

Instead, we have thrown ArithmeticException manually by using <em>throw</em> keyword:

<em>throw new ArithmeticException("Can't take square root of negative number");</em>

3 0
2 years ago
Which type of broadband internet access involves using cellular data networks? ​?
lesya [120]
The type of broadband internet access that involves using cellular data networks is mobile.
6 0
2 years ago
If a filesystem has a block size of 4096 bytes, this means that a file comprised of only one byte will still use 4096 bytes of s
jenyasd209 [6]

Answer:

Python code given below

Explanation:

def calculate_storage(filesize):

   block_size = 4096

   full_blocks = filesize // block_size

   partial_block = filesize % block_size

   if partial_block > 0:

       return (full_blocks + 1) * block_size

   return filesize

print(calculate_storage(1))

print(calculate_storage(4096))

print(calculate_storage(4097))

8 0
2 years ago
Read 2 more answers
Sang ayon kaba sa pahayag na walang sinuman ang nabubuhay para sa sarili lamang? bakit?
d1i1m1o1n [39]
What language is this?
7 0
2 years ago
Other questions:
  • Shaniya has misspelled a scientific name in her biology report. She needs to correct it, but she has no access to a computer. Sh
    13·2 answers
  • In a graphical user interface, which is a small symbol on the screen whose location and shape changes as a user moves a pointing
    10·1 answer
  • Write a program named SortWords that includes a method named SortAndDisplayWords that accepts any number of words, sorts them in
    10·1 answer
  • CodeHS Python Rainforest Exercise 5.4.7: Categories
    12·1 answer
  • To be eligible for the leadership training program offered by the office, a student must have at least 2 years of post-secondary
    9·1 answer
  • What is an input to the Program Increment Planning process that highlights how Product Management plans to accomplish the Vision
    15·1 answer
  • You should see an error. Let's examine why this error occured by looking at the values in the "Total Pay" column. Use the type f
    14·1 answer
  • You modify a document that is saved on your computer. Where are the changes stored until you save the document again?
    12·1 answer
  • Recall that a Set is an abstract data type somewhat similar to a Bag, they can store a finite collection of objects without any
    8·1 answer
  • Describe the ways in which a computer-aided design (CAD) drawing makes the details of an image easier to understand.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!