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
Simora [160]
3 years ago
15

What is the value of the cost variable after the following code snippet is executed? int cost = 82; if (cost < 100) { cost =

cost + 10; } if (cost > 50) { cost = cost * 2; } if (cost < 100) { cost = cost - 20; }
Computers and Technology
1 answer:
KonstantinChe [14]3 years ago
8 0

Answer:

184

Explanation:

Given the codes

  1.        int cost = 82;
  2.        if (cost < 100)
  3.        {
  4.            cost = cost + 10;
  5.        }
  6.        if (cost > 50)
  7.        {
  8.            cost = cost * 2;
  9.        }
  10.        if (cost < 100)
  11.        {
  12.            cost = cost - 20;
  13.        }

The initial value of cost is 82.

The if condition in Line 3 will pass and therefore cost = 82 + 10 = 92

The if condition in Line 8 will pass and therefore cost = 92 * 2 = 184

The if condition in Line 13 will fail l and therefore the if block will be skipped.

At last, the we get cost = 184.

You might be interested in
Given the following class: Create a class MyGenerator that can be used in the below main method.
natali 33 [55]

Answer:

Explanation:

The below code shows the complete code for the project. we have used Math.random() as a means of generating a random double value in the getRandom() method since it is not specified.

class Random {

          \ \ \ \ \ \ \ \ \mathbf{  public  \ static \  void  \ main \ (String[] \  args) \ \   \{}

               perform(new MyGenerator());

       }  

           \mathbf{private  \ static \  abstract  \ class  \ Generator \{ \ }

                  \mathbf{ \ protected  \ abstract  \ double \  getRandom();}

       }  

       public static <T extends Generator> void perform(T g) {

               \mathbf{System.out.println(g.getRandom());}

       }  

       // MyGenerator class inherited from Generator

       public static class MyGenerator extends Generator {

               // implementing abstract method getRandom() of Generator class

               \mathbf{Override}

               \mathbf{protected \  double  \ getRandom() \{ }

                       //returning a single double value between 0.0 and 1.0

                       \mathbf{return \ Math.random();}

               }

       }

}

/*OUTPUT (will be random)*/

0.53296649765

4 0
3 years ago
Given that the input A is false, the input B is false, and the input C is true, what is the resulting value of the output?
Debora [2.8K]

Answer:

out put is false

Explanation:

I hope it's helpful

6 0
2 years ago
The attacker sent data that was able to manipulate the return address that is reserved to store expected data
KatRina [158]

Complete Question:

An attacker gained remote access to a user's computer by exploiting a vulnerability in a piece of software on the device. The attacker sent data that was able to manipulate the return address that is reserved to store expected data. Which vulnerability exploit resulted from the attacker's actions?

Answer:

A buffer overflow.

Explanation:

In Computer science, a buffer can be defined as a temporary area set aside for data storage. Buffers reside in the random access memory (RAM).

In the event that, a system process or program places more data (much more than what was originally or initially intended to be allocated for data storage) in a buffer, the extra data overflows. Consequently, this would result in having some of the data to flow into other buffers and thus, causing the data to be overwritten or corruption of the data being held in that buffer.

For example, we can liken a buffer-overflow to pouring water (data) into a container (program memory), once it is filled the water begins to overflow as the container has reached its maximum amount.

In this scenario, the vulnerability exploit which resulted from the attacker's actions by manipulating the return address that is reserved to store an expected amount of data is referred to as a buffer overflow.

3 0
3 years ago
To change the size of a field or record by dragging its border a.resize b.magnify c.label d.enlarge
4vir4ik [10]
A. Resize

By dragging the border of a field or record, you are either enlarging it or compressing it. Choices "b" and "d" are only half correct, as there is always the possibility of making it smaller. Hope this helps!
6 0
3 years ago
Read 2 more answers
Explain: The fetch part of fetch decode execute cycle
MArishka [77]

Answer:

Look at the image

Explanation:

7 0
3 years ago
Other questions:
  • The Tell Me feature also includes access to the _____ feature.
    13·1 answer
  • Under which tab can you find the options for reusing slides from other presentations
    5·1 answer
  • A ______________ is a document created when planning resource management to help promote teamwork and clarify team communication
    13·1 answer
  • After modifying the /etc/default/grub file, what command should be run to rebuild the grub config files?​
    6·1 answer
  • Each warning label must contain this element and its purpose is to provide a visual alert to users to the chemical hazards to wh
    14·2 answers
  • What kind of music you guys play
    5·2 answers
  • How to write conclusion of hard disk​
    11·1 answer
  • Horizontal and vertical flips are often used to create ___.
    12·1 answer
  • Está dentro del gabinete del CPU es electrónica y hace que la transferencia de datos se realice contra gran rapidez / ayuda vien
    6·1 answer
  • What are web site and web page?​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!