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
Basile [38]
3 years ago
9

Write an expression that will cause the following code to print "Equal" if the value of sensorReading is "close enough" to targe

tValue. Otherwise, print "Not equal". Ex: If targetValue is 0.3333 and sensorReading is (1.0/3.0), output is: Equal
Computers and Technology
1 answer:
natali 33 [55]3 years ago
5 0

Answer:

The C++ code is given below with appropriate comments

Explanation:

//Remove this header file if not using visual studio.

#include "stdafx.h"

//Include the required header files.

#include <iostream>

//Use for maths function.

#include <cmath>

using namespace std;

//Define main function

int main()

{

      // Define the variables

      double targetValue = 0.3333;

      double sensorReading = 0.0;

      //Perform the opeartion.

      sensorReading = 1.0 / 3.0;

      // Get the absolute floating point value and

      // Check up to 4 digits.

      if (fabs(sensorReading - targetValue) < 1E-4)

      {

             //Print equal if the values are close enough.

             cout << "Equal" << endl;

      }

      else

      {

             //Print not equal if the values are not                  

             //close enough.

             cout << "Not equal" << endl;

      }

      system("pause");

      //Return the value 0.

      return 0;

}

You might be interested in
When an interrogator speaks highly about how a crime was committed, hoping to get the suspect to brag about his or her involveme
Alexeev081 [22]

I’d go with b. egotistical, i’m not entirely sure though. It seems like he is trying to appeal to the suspects EGO

8 0
3 years ago
Read 2 more answers
Select the correct answer. Larry finds it easy to run legacy programs and applications in a virtualized environment. How does th
muminat

The answer is B: installs and runs different versions of an operating system on the same computing device

Virtual machines are like guest operating systems or application environments that give you the perception that you are physically connected to a different box. A system virtual machine, for instance, copies all the components and processes of a real computer. It helps the user experiment with different operating systems and applications without the need to install them on your physical hardware.


8 0
3 years ago
Programming challenge description: Given a string comprising just of the characters (,),{,},[,] determine if it is well-formed o
nadezda [96]

Answer:

Employing Java language,

Explanation:

//for using stack data structure

import java.util.Stack;

//class definition

public class BracketMatch {

   //function to find the string is well formed or not

   public static boolean isWellFormed(String str) {

       //variable to store the character value

       char ch;

       //check if the first character itself is the end of the brackets

       if (str.charAt(0) == ')'||str.charAt(0) =='}'||str.charAt(0) ==']')

           return false;

       //creating a stack of character type

       Stack<Character> stack = new Stack<Character>();

       //iterating through the characters in string

       for(int i=0; i < str.length(); i++) {

           //storing the current character from the string in the variable

           ch = str.charAt(i);

           if(ch == '('||ch=='{'||ch=='[')

               //if the character is starting of the brackets push it into stack

               stack.push(ch);

           else if(ch == ')')

               //if it is closing bracket and the stack is empty then the string is not well formatted

               if(stack.empty())

                   return false;

               else if(stack.peek() == '(')

                   stack.pop();

               else

                   return false;

           else if(ch == '}')

               if(stack.empty())

                   return false;

               else if(stack.peek() == '{')

                   stack.pop();

               else

                   return false;

       }

       //returning the stack content, if the string will be well formed the stack would be empty

       //after all the operations

       return stack.empty();

   }

   //main method

   public static void main(String[] args) {

       //calling function to find if the string is welll formatted or not

       System.out.println(isWellFormed("{}"));

       //calling function to find if the string is welll formatted or not

       System.out.println(isWellFormed("([)]"));

   }

}

5 0
3 years ago
Which of the following is an online library?
Mice21 [21]
Answer A. Hope it helped c:
4 0
3 years ago
Read 2 more answers
Password combined with pin used as an authentication requirement is an example of:
Bingel [31]
...something that the user knows.
4 0
3 years ago
Other questions:
  • One way to describe the note-taking tool eNotes is to call it an<br> Someone help ._.
    9·2 answers
  • The syntax for multiplication function is ____________.
    8·1 answer
  • A typical self-expelling fire extinguisher empties its contents in
    8·1 answer
  • Suppose your SOHO network connects to the Internet using cable modem. When you open your browser and try to access a web site, y
    8·1 answer
  • Which computer device is used to capture or copy a photograph to place in a report?
    14·1 answer
  • Please help!! Even if you help a little I will be very thankful!
    7·1 answer
  • In addition to using comments and track changes, you can also use the comparison feature for reviewing documents. In this activi
    11·1 answer
  • Assembly (Procedure and Conditional Processing). For the following program, what are outputs for register EAX, EBX, ECX, and EDX
    11·1 answer
  • How are IP addresses usually written?
    7·1 answer
  • A short-range wireless network is called:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!