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
valkas [14]
4 years ago
6

Copy the following code and run it. You should break it into the following 3 functions

Computers and Technology
1 answer:
Darya [45]4 years ago
6 0

Answer:

The solution code is as follows:

  1. #include <iostream>
  2. using namespace() std;
  3. const double PI = 3.14159;
  4. int getValidInput() {
  5.    int radius;
  6.    cout << "Type a -1 for radius to exit" << endl;
  7.    cout << "Enter the radius: ";
  8.    cin >> radius;
  9.    
  10.    while(radius < 0){
  11.        cout << "Type a -1 for radius to exit" << endl;
  12.        cout << "Enter the radius: ";
  13.        cin >> radius;
  14.    }
  15.    return radius;
  16. }
  17. double circleCalculations(int r){
  18.    
  19.        double circ = 2 * PI * r;
  20.        double area = PI * pow(r, 2);
  21.        return area;
  22. }
  23. void printResults(int r, double a){
  24.    
  25.    cout.setf(ios::fixed);
  26.    cout.precision(1);
  27.    cout << "A circle with radius " << r << " has a circumference of "
  28.    << circ << " and an area of " << a << endl << endl;  
  29. }
  30. int main()
  31. {
  32.    int radius;
  33.    double area;
  34.    double circ;
  35.    radius = getValidInput();
  36.    area = circleCalculations(radius);
  37.    printResults(radius, area);
  38. }

Explanation:

In this question, we can identify three main functional blocks from the original codes. We cut the block of codes that ask for user input radius and paste it into the new function getValidInput() (Line 6 - 9). However, we need to add the code in Line 11-15 to ensure only the radius with valid value will be returned.

Next, we can proceed to cut another block of code that calculate the circumference and area and paste it into function circleCalculations (Line 19 -24).

Next, we cut the code that display the radius and area and paste it to function printResults(Line 26-32).

At last, we call all the three functions in the main program (Line 39-41).

You might be interested in
If the code for CAT is ECV what is the code for DOG? *
masha68 [24]
This seems to be a ROT2 Ceasar cipher. Replace each letter with a letter two places futher in the alphabet. Do the same with DOG and get <span>FQI.</span>
3 0
3 years ago
Read 2 more answers
Write 5 things that are key to writing a email.
Hitman42 [59]

Answer:

5 steps to writing an email-

Salutation

Subject

Professional

Sign

Keep it to the points

8 0
3 years ago
Which of the following is the most common tool that Windows administrators use on the domain controller?
baherus [9]

Answer:

D. The Active Directory Users and Computers

Explanation:

The Active Directory Users and Computers (ADUC) is one of the many tools used to administer the Active Directory and it is the most common tool that Windows admins use on the domain controller. It provides most of the admins functions such as

i. resetting of password

ii. unlocking users

iii. delegating of permissions to users to manage group policy

iv. managing Active Directory objects - users, computers, contacts, groups - and their attributes.

Other tools are Active Directory Component Services (allows to manage component services), Active Directory Domains and Trusts (allows to manage trusts between forests and domains), Active Directory Administrative Center (allows to manage password policies and even get the history of PowerShell logs).

<em>Hope this helps!</em>

3 0
3 years ago
Why some programming languages use compilers and other interpreters ?​
Inga [223]

Answer:

A compiler takes a lot of time to analyze the source code. However, the overall time taken to execute the process is much faster. An interpreter does not generate an intermediary code. Hence, an interpreter is highly efficient in terms of its memory.

Explanation:

5 0
3 years ago
Cloud kicks recently completed the implementation of sales cloud. Cloud kicks has trained the users to use the mobile app to acc
aleksandrvk [35]

Answer:

see how long the people are on the app and see low long te time is constant where nobody is on at all

Explanation:

7 0
4 years ago
Other questions:
  • You have been asked to create an authentication security plan for your company. Which of the following components would you inco
    14·1 answer
  • Which of the following would you click to access Help and Support?
    6·2 answers
  • To collect data using Google Analytics, which steps must be completed? (select all answers that apply)
    9·1 answer
  • If your driving privilege is suspended or revoked you may be eligible to apply for a hardship license or reinstatement to determ
    13·2 answers
  • Why was the internet originally constructed
    5·1 answer
  • What are the first steps that you should take if you're unable to get onto the internet
    13·2 answers
  • #Write a function called 'string_type' which accepts one #string argument and determines what type of string it is. # # - If the
    8·1 answer
  • Why hasn’t the World Health Organization declared a global health emergency?
    5·1 answer
  • What information is stored in the file system?
    5·1 answer
  • What is an undirected graph?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!