LO: (Analyze) Students will fix a loop that runs forever. main.cpp O New #include 2 using namespace std; This program runs the countdown sequence for a rocket launch. However, it seems 3. to loop infinitely. Fix the program so it counts down and terminates properly. 4- /* * Counts down to blastoff, starting from a given number. 6. */ 7- int main() { int countdown 8 -10; cin >> countdown; while (countdown != 0) { cout <« countdown << 9. 10 - 11 <« endl; 12 countdown--; 13 cout « "Blast off!" << endl; turn 0; 14 15 16 }

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 4PP: (Numerical) Write and test a function that returns the position of the largest and smallest values...
icon
Related questions
Question
LO: [Analyze) Students will fix a loop that runs forever.
maln.cpp
New
1
#include <iostream>
2 using namespace std;
This program runs the countdown sequence for a rocket launch. However, it seems
3
to loop infinitely. Fix the program so it counts down and terminates properly.
4- /*
5
* Counts down to blastoff, starting from a given number.
6.
*/
7- int main() {
int countdown
cin >> countdown;
while (countdown != 0) {
cout <« countdown <«
-10;
10 -
11
endl;
12
countdown--;
13
}
cout <« "Blast off!" << endl;
return 0;
14
15
16 }
Transcribed Image Text:LO: [Analyze) Students will fix a loop that runs forever. maln.cpp New 1 #include <iostream> 2 using namespace std; This program runs the countdown sequence for a rocket launch. However, it seems 3 to loop infinitely. Fix the program so it counts down and terminates properly. 4- /* 5 * Counts down to blastoff, starting from a given number. 6. */ 7- int main() { int countdown cin >> countdown; while (countdown != 0) { cout <« countdown <« -10; 10 - 11 endl; 12 countdown--; 13 } cout <« "Blast off!" << endl; return 0; 14 15 16 }
LO: (Apply) Students will compute a value from multi-dimensional data.
LO: (Apply] Students will find the optimal value in a collection.
A group of farmers are using drones to gather data about how much corn they have grown in their plots. The plots are organized in rows, where each row has the same number of plots. The rows are numbered starting
from row 0, the closest row to the farm house. The plots are also numbered starting from plot 0.
The farmers want to know which row had the highest crop yield (how much corn grew). Write a program to find the row with the highest crop yield. If rows are tied for the highest yield, choose the closest row to the farm
house
These methods will help you access the crop data:
void loadcropData()
int getRowcount()
int getRowLength()
int getcropCount (int row, int plot)
Call loadcropData() only once, at the start of your program.
• Call getRowcount() to get an integer representing the number of rows in the field.
Call getRowLength() to get an integer representing the number
• Call getcropCount (r, p) to get an integer representing the number of bushels of corn in plot p of row r.
plots in each row.
Note: Include crops.cpp in order to access the helper functions.
Note: Refer to corn.data for a sample data file. The first value is the number of rows, the second value is the number of plots, and then the remaining values represent the plot yields in row, then plot order.
Transcribed Image Text:LO: (Apply) Students will compute a value from multi-dimensional data. LO: (Apply] Students will find the optimal value in a collection. A group of farmers are using drones to gather data about how much corn they have grown in their plots. The plots are organized in rows, where each row has the same number of plots. The rows are numbered starting from row 0, the closest row to the farm house. The plots are also numbered starting from plot 0. The farmers want to know which row had the highest crop yield (how much corn grew). Write a program to find the row with the highest crop yield. If rows are tied for the highest yield, choose the closest row to the farm house These methods will help you access the crop data: void loadcropData() int getRowcount() int getRowLength() int getcropCount (int row, int plot) Call loadcropData() only once, at the start of your program. • Call getRowcount() to get an integer representing the number of rows in the field. Call getRowLength() to get an integer representing the number • Call getcropCount (r, p) to get an integer representing the number of bushels of corn in plot p of row r. plots in each row. Note: Include crops.cpp in order to access the helper functions. Note: Refer to corn.data for a sample data file. The first value is the number of rows, the second value is the number of plots, and then the remaining values represent the plot yields in row, then plot order.
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
Array
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr