c++ PE04 - Functions and Prototypes For this exercise, you'll complete two problems. Problem 1 - Function Declarations Write the prototypes for several function calls, deducing the correct signature from the context in PrototypeTester.cpp Do not implement the functions themselves. That is already done. Place the prototypes in pe04.h. Problem 2 - Write a Function Write a function named quadratic() which computes roots of quadratic equations. Recall that a quadratic equation is one of the form, ax2 + bx + c = 0. Your function accepts five arguments: The integer coefficients a, b, and c as three input parameters. Two real number (double) output parameters root1 and root2. Your function should compute the two roots of the quadratic equation and store them into the two output parameters. For example, the equation x2 - 3x - 4 = 0 has roots of x = 4 and x = -1, so the call: double root1, root2; quadratic(1, -3, -4, root1, root2); should set root1 to 4.0 and root2 to -1.0. You may assume that the function has two real roots. Recall that the quadratic formula is: Constraints: You should not use any built-in functions from the system libraries except for sqrt() from the  header. You must program this function by "hand". pe04.h    #ifndef PE04_H  #define PE04_H  #include   // PLACE YOUR PROTOTYPES BELOW THIS LINE   // PUT YOUR PROTOTYPES ABOVE THIS LINE #endif Use this following file: PrototypeTester.cpp #include #include #include #include "checker.h" using namespace std; #include "pe04.h" int main() { // A. --------------------------------------------------------- cout << defined(true, 3.5, "Hello", 75) << endl; // prints 150 cout << "Expected: 150" << endl; // B. --------------------------------------------------------- string v = "p1.cpp"; bool okA; double x; int ba = 5; cout << compile(v, okA, ba, x) << endl; cout << "Expected: 12.5" << endl; // changed->okA->true, x->2.5, v not changed, ba not changed // C. --------------------------------------------------------- cout << seekDir(2.5, 'x') << endl; // prints 0.0 cout << "Expected: 0.0" << endl; // D. --------------------------------------------------------- bool okB = false; cout << closeDir(2.5, 'x', okB) << endl; cout << "Expected: 5" << endl; // prints 5, okB->true // E. --------------------------------------------------------- bool okC; long long seekPos = 107LL; const string POS_NAME = "CUR_DIR"; cout << rewindDir(POS_NAME, okC, 1.5, seekPos) << endl; cout << "Expected: X" << endl; // prints 'X', okC->true, seekPos->102LL } pe04.cpp #include using std::sqrt; // Write your function here

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

c++

PE04 - Functions and Prototypes

For this exercise, you'll complete two problems.

Problem 1 - Function Declarations

Write the prototypes for several function calls, deducing the correct signature from the context in PrototypeTester.cpp Do not implement the functions themselves. That is already done. Place the prototypes in pe04.h.

Problem 2 - Write a Function

Write a function named quadratic() which computes roots of quadratic equations. Recall that a quadratic equation is one of the form, ax2 + bx + c = 0.

Your function accepts five arguments:

  • The integer coefficients a, b, and c as three input parameters.
  • Two real number (double) output parameters root1 and root2.

Your function should compute the two roots of the quadratic equation and store them into the two output parameters. For example, the equation x2 - 3x - 4 = 0 has roots of x = 4 and x = -1, so the call:

double root1, root2; quadratic(1, -3, -4, root1, root2);

should set root1 to 4.0 and root2 to -1.0.

You may assume that the function has two real roots. Recall that the quadratic formula is:

Constraints: You should not use any built-in functions from the system libraries except for sqrt() from the <cmath> header. You must program this function by "hand".

pe04.h

 
 #ifndef PE04_H
 #define PE04_H
 #include <string>
 

// PLACE YOUR PROTOTYPES BELOW THIS LINE

 

// PUT YOUR PROTOTYPES ABOVE THIS LINE

#endif

Use this following file:

PrototypeTester.cpp

#include <iostream> #include <string> #include <vector> #include "checker.h" using namespace std; #include "pe04.h" int main() { // A. --------------------------------------------------------- cout << defined(true, 3.5, "Hello", 75) << endl; // prints 150 cout << "Expected: 150" << endl; // B. --------------------------------------------------------- string v = "p1.cpp"; bool okA; double x; int ba = 5; cout << compile(v, okA, ba, x) << endl; cout << "Expected: 12.5" << endl; // changed->okA->true, x->2.5, v not changed, ba not changed // C. --------------------------------------------------------- cout << seekDir(2.5, 'x') << endl; // prints 0.0 cout << "Expected: 0.0" << endl; // D. --------------------------------------------------------- bool okB = false; cout << closeDir(2.5, 'x', okB) << endl; cout << "Expected: 5" << endl; // prints 5, okB->true // E. --------------------------------------------------------- bool okC; long long seekPos = 107LL; const string POS_NAME = "CUR_DIR"; cout << rewindDir(POS_NAME, okC, 1.5, seekPos) << endl; cout << "Expected: X" << endl; // prints 'X', okC->true, seekPos->102LL }

pe04.cpp

#include <cmath>
using std::sqrt;

// Write your function here

 
 
 
 
 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Events
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education