4. 5 #include 6 #include 7 using namespace std; 8 9 int main() 10 { 11 int day 0; 12 13 14 15 16 17 { int totalTexts = 0; int dailyTexts 0; double average = 0.0; %3! %3D for (day = 1; day < 8; day += 1) %3! 18 19 20 21 22 cout << "How many text messages did you send on day <« day << "? "; cin >> dailyTexts; totalTexts += dailyTexts; } //end for maldo 23 24 average = static_cast(totalTexts) / (day - 1); cout <« fixed << setprecision(0); 26 cout « endl << "You sent approximately " <« average << 25 %3D 27 %3D text messages per day." « endl; return 0; 29 } //end of main function 28 Figure 7-38 wo QUESTIONS 0n n Code for Lab 7-1 1. What is the name of the program's counter variable? What is the name of its accumulator variable? 2. What is another way of phrasing the for clause's condition argument? 3. Why is the for statement's counter variable declared at the beginning of the program (in Line 11) rather than in the for clause? Would the program work correctly if the variable was declared in the for clause?

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question
3 //Created/revised by <your name> on <current date>
1 //Lab7-1.cpp - calculates the average number of text
program calculates and displays the average number of text messages sent each day
LAB 7-1 Stop and Analyze
Study the program shown in Figure 7-38, and then answer the questions. The
m for seven days.
The answers
to the labs are
2 //messages sent each day for 7 days
contained in the
Answers.pdf file.
Ow w G
4
5 #include <iostream>
6 #include <iomanip>
7 using namespace std;
o cut
8
9 int main()
10 {
11
12
13
int day = 0;
int totalTexts = 0;
int dailyTexts = 0;
double average = 0.0;
14
15
16
emaldo
for (day = 1; day < 8; day += 1)
{
bne nak lw uoy dil irn
17
18
19
20
21
cout << "How many text messages did you send on day
<« day << "? ";
cin >> dailyTexts;
totalTexts += dailyTexts;.
//end for
inuoms
maldo
22
23
24
uorme 2elsa
average = static_cast<double>(totalTexts) / (day - 1); |
cout << fixed << setprecision(0);
cout << endl << "You sent approximately
25
26
27
28
29 } //end of main function
emit ts oms
<« average « " text messages per day." << endl;
return 0;
Code for Lab 7-1
198
Figure 7-38
QUESTIONS
1. What is the name of the program's counter variable? What is the name of its
accumulator variable?
2. What is another way of phrasing the for clause's condition argument?
3. Why is the for statement's counter variable declared at the beginning of the program (in
Line 11) rather than in the for clause? Would the program work correctly if the variable
was declared in the for clause?
Transcribed Image Text:3 //Created/revised by <your name> on <current date> 1 //Lab7-1.cpp - calculates the average number of text program calculates and displays the average number of text messages sent each day LAB 7-1 Stop and Analyze Study the program shown in Figure 7-38, and then answer the questions. The m for seven days. The answers to the labs are 2 //messages sent each day for 7 days contained in the Answers.pdf file. Ow w G 4 5 #include <iostream> 6 #include <iomanip> 7 using namespace std; o cut 8 9 int main() 10 { 11 12 13 int day = 0; int totalTexts = 0; int dailyTexts = 0; double average = 0.0; 14 15 16 emaldo for (day = 1; day < 8; day += 1) { bne nak lw uoy dil irn 17 18 19 20 21 cout << "How many text messages did you send on day <« day << "? "; cin >> dailyTexts; totalTexts += dailyTexts;. //end for inuoms maldo 22 23 24 uorme 2elsa average = static_cast<double>(totalTexts) / (day - 1); | cout << fixed << setprecision(0); cout << endl << "You sent approximately 25 26 27 28 29 } //end of main function emit ts oms <« average « " text messages per day." << endl; return 0; Code for Lab 7-1 198 Figure 7-38 QUESTIONS 1. What is the name of the program's counter variable? What is the name of its accumulator variable? 2. What is another way of phrasing the for clause's condition argument? 3. Why is the for statement's counter variable declared at the beginning of the program (in Line 11) rather than in the for clause? Would the program work correctly if the variable was declared in the for clause?
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Parallel Processing
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage