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
leonid [27]
3 years ago
10

Copy the main given below. Write the methods needed to produce the output given. YOU SHOULD NOT CHANGE MAIN

Computers and Technology
1 answer:
Bad White [126]3 years ago
4 0

Answer:

C++ code explained below

Explanation:

CODE

#include <iostream>

using namespace std;

// prototypes go here

void getInput(double *l, double *w) {

cout << "Enter Length: ";

cin >> *l;

if(*l < 0) {

return;

}

cout << "Enter Width: ";

cin >> *w;

while(*w < 0) {

cout << "Width must be positive! Try Again" << endl;

cout << "Enter Width: ";

cin >> *w;

}

}

double calculations(double l, double w, double *perimeter) {

*perimeter = 2 * (l + w);

return l*w;

}

void printResults(double l, double w, double perimeter, double area) {

cout << "Rectangle Dimensions: " << l << " X " << w << endl;

cout << "perimeter: " << perimeter << endl;

cout << "Area: " << area << endl;

return;

}

int main()

{

double t;

// test(&t);

double length;

double width;

double perimeter;

double area;

//below line has to change if you need to work this example

//reason is length and width are local variable to main so other function can only change if address is passed so i have plase & sign before the variables while passing

//same has to be done for perimeter

getInput(&length, &width);

while (length >= 0)

{

area = calculations(length, width, &perimeter);

printResults(length, width, perimeter, area);

getInput(&length, &width);

}

}

You might be interested in
Able to make a survey form using VB (Visual basics 6.0) to represent ways of conservation of
Nadusha1986 [10]
40 is the right answer
6 0
3 years ago
Read 2 more answers
Write a program that will print out statistics for eight coin tosses. The user will input either an "h" for heads or a "t" for t
shusha [124]

Answer:

Written in Python

head = 0

tail = 0

for i in range(1,9):

     print("Toss "+str(i)+": ")

     toss = input()

     if(toss == 'h'):

           head = head + 1

     else:

           tail = tail + 1

print("Number of head: "+str(head))

print("Number of tail: "+str(tail))

print("Percent head: "+str(head * 100/8))

print("Percent tail: "+str(tail * 100/8))

Explanation:

The next two lines initialize head and tail to 0, respectively

head = 0

tail = 0

The following is an iteration for 1 to 8

<em>for i in range(1,9): </em>

<em>      print("Toss "+str(i)+": ") </em>

<em>      toss = input()  </em><em>This line gets user input</em>

<em>      if(toss == 'h'):  </em><em>This line checks if input is h</em>

<em>            head = head + 1 </em>

<em>      else:  </em><em>This line checks otherwise</em>

<em>            tail = tail + 1 </em>

The next two lines print the number of heads and tails respectively

print("Number of head: "+str(head))

print("Number of tail: "+str(tail))

The next two lines print the percentage of heads and tails respectively

print("Percent head: "+str(head * 100/8))

print("Percent tail: "+str(tail * 100/8))

3 0
3 years ago
Write a program to assign and display a string value to any variable of your choice
vazorg [7]

Answer:

How to create a string and assign it to a variable. To create a string, put the sequence of characters inside either single quotes, double quotes, or triple quotes and then assign it to a variable.

6 0
3 years ago
Truck drivers probably can't see your vehicle if ______________.
Arada [10]
<h2>Answer:</h2>

Truck drivers probably can't see your vehicle if you cannot see them in their side mirror

<h2>Explanation:</h2>

In driving terminology there is a term called the bind spot. Blind spot is the area where the driver is not able to see the vehicle behind him and this area is present just behind the truck and very close to the gates of the car. Since trucks do not have the rare mirror therefore if a car is present in their blind spot they wont be able to see it. The driver behind the truck can spot it if he does not see the truck driver in the side mirror of the truck.

5 0
3 years ago
Read 2 more answers
Which of the following is an example of hypertext pattern reading?
Murrr4er [49]
A is the correct answer
5 0
3 years ago
Other questions:
  • Nadia would like to find text in her current document that differentiates CompanyABC from companyabc. Which option should she us
    8·2 answers
  • What is a taskbar?
    5·1 answer
  • Learning about public speaking can help improve your ________________.
    15·1 answer
  • Differentiate between third and fourth generation of computer​
    6·1 answer
  • Summarizes statistical data ?
    11·1 answer
  • Anyone trying to play fortnite ? im bored lol
    6·2 answers
  • If String str = "Computer Science";, then what is the value of str.substring(10);? ​
    6·1 answer
  • Merging refers to dividing a single cell into multiple cells. *TrueFalse
    14·1 answer
  • Examples of how the development of coding changed the way we live. What type of technology was created as a result of code?
    10·1 answer
  • When viewing an e-book section of an assignment in launchpad, you can return to your main course page at any time by clicking th
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!