Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 //Function: cla9a.cpp 2 //Author: 3 //Purpose: This program updates a checking account given the 4 // starting balance and the amount of the 5

1 //Function: cla9a.cpp 2 //Author: 3 //Purpose: This program updates a checking account given the 4 // starting balance and the amount of the 5 // check written against the account. 6 7 #include 8 #include 9 using namespace std; 10 11 // Function Prototypes 12 void PrintStars(); 13 void Heading(); //display bank heading 14 void GetData(float&, float&); //get balance & check amt 15 void PrintInfo(float, float, float, bool); //display results 16 17 int main() 18 { 19 20 //local declarations... 21 float oldBalance; //starting balance of the account 22 float check; //amount of the check 23 float balance; //new balance 24 bool overDrawn; //Is the account over drawn? 25 26 //get the starting balance and check amount 27 GetData(oldBalance, check); 28 29 //print a heading 30 Heading(); 31 32 //calculate the new balance and determine whether the account is overdrawn 33 balance = oldBalance - check; 34 if (balance 35 overDrawn = true; 36 else 37 overDrawn = false; 38 39 //print the results 40 PrintInfo(oldBalance, check, balance, overDrawn); 41 PrintStars(); 42 43 return 0; 44 } 45 46 // Input starting checking balance and amount of check. 47 void GetData(float& old, //OUT: starting account balance 48 float& amount) //OUT: check amount 49 { 50 51 cout 52 cout \" 53 cin >> old; 54 cout \" 55 cin >> amount; 56 return; 57 } 58 59 // Print a heading for the bank statement. 60 void Heading() 61 { 62 cout 63 cout 64 cout 65 PrintStars(); 66 PrintStars(); 67 cout \"*****************fourth> 68 cout \"> 69 cout 70 cout 1515 ONE TIME STREET\" 71 cout MANY APPLES, MINNESOTA\"; 72 PrintStars(); 73 PrintStars(); 74 return; 75 } 76 77 // Print all banking information. 78 void PrintInfo(float old, //IN: starting balance 79 float amount, //IN: check amount 80 float bal, //IN: ending balance 81 bool over) //IN: over drawn indicator 82 { 83 cout 84 cout 85 cout OLD BALANCE CHECK AMOUNT NEW BALANCE\"; 86 cout OVER DRAWN\" 87 cout 88 cout 89 cout 90 cout 91 cout \" 92 cout 93 return; 94 } 95 96 // Print decorative stars. 97 void PrintStars() 98 { 99 cout 100 cout 101 cout 102 }

Exercise 1: Look at the program called cla9a.cpp. On the answer sheet, answer the following questions. Note that line numbers have been added to help you identify certain parts of this program.

a. Which lines of the program contain functionprototypes?

b. Which lines of the program contain the functiondefinitionof the functionPrintInfo?

c. Which line of the programactivates(calls) the functionPrintInfo?

d. Name allvoidfunctions withno parameters(if any).

e. Name allvoidfunctions withvalue parameters(if any).

f. Name allvoidfunctions withreference parameters(if any).

g. Name thelibraryfunctions (if any) used in the program.

========================================================================================

PLEASE DO ALL OF THEM FOR ME THANK YOU

1 //FILE: cla9b.cpp 2 // 3 //PURPOSE: This program evaluates a quadratic equation of the 4 // form: 5 // ax^2 + bx + c 6 // 7 // at a value for x which is input interactively. 8 9 //include files... 10 #include 11 #include 12 13 using namespace std; 14 15 //function prototype 16 float Quadratic(float, float, float, float); //evaluate a quadratic 17 18 int main() 19 { 20 //local variables... 21 float a, b, c; //coefficients of ax^2 + bx + c 22 float value; //value at which the quadratic will be evaluated 23 float answer; //value of the quadratic equation 24 bool keepGoing; //Does the user want to continue? 25 char response; //The user's response to continue or not 26 27 //we want to run this at least once! 28 keepGoing = true; 29 30 //as long as the user wants to process quadratic equations 31 //do this loop 32 while (keepGoing) 33 { 34 //Read in values a, b, c, and x 35 cout 36 \"> 37 cin >> a >> b >> c; 38 cout 39 cout 40 cin >> value; 41 42 //Evaluate the quadratic 43 answer = Quadratic(a,b,c, value); 44 45 //Display the results 46 cout 47 cout 48 cout 49 cout 50 cout 51 cout 52 53 //Does the user want to continue? 54 cout 55 cin >> response; 56 if (response == 'N') 57 keepGoing = false; 58 } 59 //end of main... 60 return 0; 61 62 } 63 64 //Function: Quadratic() 65 //Purpose: To evaluate and return the quadratic ax^2 + bx + c 66 // at the paticular value of x. 67 float Quadratic(float a, //IN: coefficient of the quadratic 68 float b, //IN: coefficient of the quadratic 69 float c, //IN: coefficient of the quadratic 70 float x) //IN: the value of x 71 { 72 // local variables... 73 float answer; //The value of the quadratic 74 75 //evaluate and return the value of the quadratic 76 answer = a * x * x + b * x + c; 77 return answer; 78 79 }

Exercise 2: Copy the file called cla9b.cpp to your account. This program contains a function calledquadratic()that receives input arguments for a, b, c, and x and evaluates a quadratic equation of the form ax2+ bx + c for a particular value of x.

By studying the code in cla9b.cpp, answer the following questions on the answer sheet:

a. Name the parameters (function heading) for the function quadratic(). b. Name the actual arguments (the arguments in the activation statement). c. What is the return type of this function?

================================================================================================

ONCE AGAIN PLS DO ALL OF THEM FOR ME. THANK YOU:) :)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intermediate Algebra

Authors: Margaret Lial, John Hornsby, Terry McGinnis

13th Edition

0134895983, 978-0134895987

More Books

Students also viewed these Programming questions

Question

please dont use chat gpt 3 2 4 . .

Answered: 1 week ago

Question

14. Let X be uniform over (0, 1). Find E[X|X Answered: 1 week ago

Answered: 1 week ago