In this lab, we will continue to explore some of the topics studied in Chapter 3
ID: 3750873 • Letter: I
Question
In this lab, we will continue to explore some of the topics studied in Chapter 3 of the text. You will have to fill in the program using guidance from the comments in the code. This is an in-class assignment grade worth 10 points. // Place your name here #include // Include the file for setprecision here using namespace std; int main() { int first, second, third; double avg; // Prompt the user to enter three numbers separated by spaces. cout << // Use ONE cin statement to read all three values (store in first, // second, and third). cin >> ; // Using static_cast to double, fix the formula variables below so that // division is done correctly. Also, fix the formula so addition is // done before division. avg = first + second + third / 3; // Print the value of avg cout << ; const double PI = 3.14159; float area, radius = 5.0; // Rewrite the line below using the pow() function. area = PI * radius * radius; // cout the value of area cout << ; int total = 0, a = 1, b = 2, c = 3, d = 4; // Rewrite the statements below to use the combined assignment // operators. total = total + d; total = total - a; total = total * c; total = total / b; cout << “Total = “ << total; //modify the cout statement below. Use fixed and setprecision //to display 4 digits after the decimal point. cout << “Average = “ << avg << endl; cout << “Area = “ << area; system(“pause”); return 0; }
Explanation / Answer
// Place your name here #include #include // Include the file for setprecision here #include using namespace std; int main() { int first, second, third; double avg; // Prompt the user to enter three numbers separated by spaces. cout > first >> second >> third; // Using static_cast to double, fix the formula variables below so that // division is done correctly. Also, fix the formula so addition is // done before division. avg = static_cast(first + second + third) / 3; // Print the value of avg coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.