Can you answer these questions in short based on the code please. #include #include #include using namespace std; // Function to calculate the stock valuation based on dividend yield string calculateValuation(double dividendYield) { if (dividendYield >= 4.5) return "Over Valued"; else if (dividendYield >= 4) return "Fairly Valued"; else return "Under Valued"; } int main() { // Initialize variables to store company information string companyName; string stockSymbol; double stockPrice; double annualDividend; // Loop to get information for five companies for (int i = 0; i < 5; i++) { // Get company information from user cout << "Enter the company name: "; getline(cin, companyName); cout << "Enter " << companyName << "'s stock symbol: "; getline(cin, stockSymbol); cout << "Enter " << companyName << "'s current stock price: "; cin >> stockPrice; cout << "Enter " << companyName << "'s annual dividend per share: "; cin >> annualDividend; cin.ignore(); // Ignore newline character left in input buffer // Calculate dividend yield and stock valuation double dividendYield = annualDividend / stockPrice * 100; string valuation = calculateValuation(dividendYield); // Output company information and valuation cout << fixed << setprecision(3); cout << companyName cout << companyName << " " << stockSymbol << " "; cout << stockPrice << " " << annualDividend << " "; cout << dividendYield << " " << valuation << endl; } return 0; }

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
Can you answer these questions in short based on the code please. #include #include #include using namespace std; // Function to calculate the stock valuation based on dividend yield string calculateValuation(double dividendYield) { if (dividendYield >= 4.5) return "Over Valued"; else if (dividendYield >= 4) return "Fairly Valued"; else return "Under Valued"; } int main() { // Initialize variables to store company information string companyName; string stockSymbol; double stockPrice; double annualDividend; // Loop to get information for five companies for (int i = 0; i < 5; i++) { // Get company information from user cout << "Enter the company name: "; getline(cin, companyName); cout << "Enter " << companyName << "'s stock symbol: "; getline(cin, stockSymbol); cout << "Enter " << companyName << "'s current stock price: "; cin >> stockPrice; cout << "Enter " << companyName << "'s annual dividend per share: "; cin >> annualDividend; cin.ignore(); // Ignore newline character left in input buffer // Calculate dividend yield and stock valuation double dividendYield = annualDividend / stockPrice * 100; string valuation = calculateValuation(dividendYield); // Output company information and valuation cout << fixed << setprecision(3); cout << companyName cout << companyName << " " << stockSymbol << " "; cout << stockPrice << " " << annualDividend << " "; cout << dividendYield << " " << valuation << endl; } return 0; }
estions:
1. Explain whether a structure was necessary and if so, explain why you composed
your structure as you did.
2. Explain whether any functions were necessary, and explain why you composed
the functions as you did.
3. Explain whether any loops were necessary, and why.
Transcribed Image Text:estions: 1. Explain whether a structure was necessary and if so, explain why you composed your structure as you did. 2. Explain whether any functions were necessary, and explain why you composed the functions as you did. 3. Explain whether any loops were necessary, and why.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Function
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
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