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
Alexxandr [17]
3 years ago
5

In this lab, you complete a partially written C++ program that includes a function that returns a value. The program is a simple

calculator that prompts the user for two numbers and an operator ( +, -, *, or / ). The two numbers and the operator are passed to the function where the appropriate arithmetic operation is performed. The result is then returned to the main()function where the arithmetic operation and result are displayed. For example, if the user enters 3, 4, and *, the following is displayed: 3 * 4 = 12
The source code file provided for this lab includes the necessary variable declarations and input and output statements. Comments are included in the file to help you write the remainder of the program.

Instructions

Write the C++ statements as indicated by the comments.
Execute the program by clicking the Run button at the bottom of the screen.

DRAFT:

// Calculator.cpp - This program performs arithmetic, ( +. -, *. / ) on two numbers.
// Input: Interactive
// Output: Result of arithmetic operation

#include
#include

using namespace std;

// Write performOperation() function declaration here

int performOperation(double numberOne, double numberTwo, string op);
int main()
{
double numberOne, numberTwo;
string operation;
double result;
cout << "Enter the first number: ";
cin >> numberOne;
cout << "Enter the second number: ";
cin >> numberTwo;
cout << "Enter an operator (+.-.*,/): ";
cin >> operation;

// Call performOperation method here

result = performOperation(numberOne,numberTwo,operation);
cout << numberOne;
cout << " " << operation << " ";
cout << numberTwo;
cout << " = ";
cout << result << endl;
return 0;
} // End of main() function

// Write performOperation function here
int performOperation(double numberOne, double numberTwo,std::string(op)){
double result;
if (op == "+")
result = numberOne + numberTwo;
else if (op == "-")
result = numberOne - numberTwo;
else if (op == "*")
result = numberOne*numberTwo;
else if (op == "/")
result = numberOne/numberTwo;
else
cout<<"Wrong input. Please try again.";
return result;
}

It's already working but it says that there's something wrong with the declared performOperation
Computers and Technology
1 answer:
inna [77]3 years ago
5 0

Answer:

In the given program the function work properly and the code for remainder section calculation can be given as:

Code:  

This code is written inside the function in conditional statement block  

else if (op == "%") //check condition  

result = numberOne % numberTwo; //holds value in result variable.  

Explanation:

The description of the code can be given as:

  • In the given program a function "performOperation" is defined that accepts three variable in which two values is number and one is sign value inside a function in the conditional statement section we add code for calculating remainder that can be defined above. This function will calculate a value and return the value.
  • In the main method, we declare a variable that is "numberOne, numberTwo, and operation" these three variables are used to take input from the user and passed into the function. To hold function return value we define a variable that is the result that holds function value and prints its value.
You might be interested in
8. Software ____ are individual programs that can be purchased, installed, and run separately, but extract data from the common
oee [108]
System software are software that can be installed and run separately
6 0
3 years ago
How to do this PLEASE HELP 80 points!
sp2606 [1]

When reading the story, you know that the code has been created by humans, so it might actually be english and use concepts like our number system, our computer code system (I'm thinking ASCII), things that you should not assume when decoding a real alien message.

Looking at the numbers I notice that digits 6 to 9 do not occur in the message, which is statistically unexpected. This leads me to believe the number base might be 6 rather than our common base 10. In the story there are insects mentioned. Insects have 6 legs, so this makes sense (after all, our base 10 was based on the number of fingers).

Next, I notice the code 052 appearing regularly, so that could be a space. Let's check a hypothesis. 052 in base 6 is 5*6+2 = 32. 32 is the ASCII code for a space!!

Now, a decoding algorithm is ready to be devised:

"for each number in the sequence, parse it as a base-6 number and then print out its corresponding ASCII value".

The following node.js snippet does this:

var code = ['220','241','255','245','052','313',

           '311','052','312','303','052','312',

           '252','245','052','205','241','251',

           '253','243','052','203','253','302',

           '251','244','303','301','053'];

           

var msg = "";

for (let n of code) {

   msg += String.fromCharCode(parseInt(n,6));

}

console.log(msg);


And the message is.........:

<em>Take us to the Magic Kingdom!</em>

So, do these aliens want to visit Disneyland????

5 0
3 years ago
A disciplined, creative, and effective approach to problem solving is needed for project success. The nine-step approach to prob
KatRina [158]

Answer: Determine the most popular solution.

Explanation:

Some of the approaches to problem solving that are listed here include:

• Gather data and verify the most likely causes.

• Revise the project plan.

• Evaluate the alternative solutions

To solve a problem, one needs to gather the data and verify the likely causes of the problem. This can be done by asking questions, running test, interviewing people, running tests, reading reports, or analyzing data.

The project plan can also be revised. Likewise, when one comes with different solutions, one should weigh the cost and benefits of each in order to choose the best solution.

Determine the most popular solution isn't a correct option.

6 0
3 years ago
I NEED HELP!!! BRAINLIEST!!!
Trava [24]

Answer:

DHCP Dynamic Host Configuration Protocol:

Is a network service that automatically assigns IP addresses and other TCP/IP configuration information on network nodes configured as DHCP clients. Server allocates IP addresses to DHCP clients dynamically. Should be configured with at least one DHCP scope. Scope contains a range of IP addresses and a subnet mask, and can contain other options, such as a default gateway and Domain Name System. Scope also needs to specify the duration of the lease and usage of an IP affects after which the node needs to renew the lease with the SHCP server. Determines the duration, which can be set for a defined time period or for an unlimited length of time.

DNS Domain Name Service: Is a TCP/IP name resolution service that translates FQDNs into IP addresses. System of hierarchical databases that are stored on separate DNS servers on all networks that connect to the Internet. DNS servers store, maintains and update databases, they respond to DNS client name resolution requests to translate host names into IP addresses.

DNS Components

DNS database is divided logically into a heieratchical grouping of domains. Physically into files called zones. Zone files contain the actual IP-to-host name mapping for one or more domains. Zone files is stored on the DNS server that is responsible for resolving hot names for the domains contained in the zone. Each network node in that domain will have a host record within the domain's zone files. Includes the node's host name, FQDN, and assigned IP address.

DNS Servers

*If you are configuring static IP addresses, including the IP address of the default DNS servers as you configure each client.

*If you are using DHCP, use the DHCP scope options to specify the IP Explanation:

3 0
3 years ago
Read 2 more answers
The use of IDPS sensors and analysis systems can be quite complex. One very common approach is to use an open source software pr
lawyer [7]

Answer:

IDP sensors can be complicated.An open-source software program called snort program.

Explanation:

Snort is an open-source network intrusion detection system (IDS) and prevention system. It is created in 1998 by Martin. Snort's open source network-based can perform analysis and packet logging on an Internet Protocol network.

The snort program can be used to detect probes or attacks. Snort configured three modes

sniffer

pocket logger

network intrusion detection.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following describes an acceptable print resolution?
    7·1 answer
  • What is the maximum amount that OSHA can impose as a penalty on an employer for each Willful violation?
    11·1 answer
  • What is the role of programmers in an organization?
    6·1 answer
  • Listed items that are not in any particular order should be identified with _____.
    9·1 answer
  • A5.3 1012 kg satellite is 1,800 m from another satellite that has a mass of 3.5 x 108 kg. What is the gravitational
    6·1 answer
  • Violations of security policies are considered to be a(n) __________ issue upon which proper disciplinary actions must be taken.
    7·1 answer
  • A Layer 2 switch configuration places all its physical ports into VLAN 2. The IP addressing plan shows that address 172.16.2.250
    7·1 answer
  • Nathaniel wanted to buy a microphone. He went to an electronics store and was told that there are actually two types of micropho
    13·2 answers
  • Write a program (main method) that advises the user on programming language. So if a user for instance enters "Java" the program
    6·1 answer
  • Text Questions
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!