Question

You need to design a program to record data for a fishing boat. You will need to ask how many crab traps were set (between 1 and 10 inclusive). Then using a loop get the trap number (each trap has a unique number) and the number of crabs caught in the pot. Find the average number caught in each pot. Then use another loop to count how many pots caught above average. Display the number of any pot catching above average. Use methods and input validation as needed

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
using namespace std;
int main() {
int n,CrabCount;
float avg = 0.0;
cout << "How many crab traps were set(1 to 10 only):";
cin>>n;
int a[n];
for(int i = 0;i<n;i++){
int j=i+1;
cout<<"please enter number of crabs trapped in "<<j<<" :";
cin>>CrabCount;
a[i]=CrabCount;
}
for(int i=0;i<n;i++){
avg=avg+a[i];
//cout<<avg<<endl;

}
cout<<"Avg is : " <<avg/n<<endl;
int count = 0;
for(int j=0;j<n;j++){
if(a[j]>(avg/n)){
count = count+1;
}

}
cout<<"Total Number of pot catching above Avg is:"<<count;
}

5 //int a[n]; 6 float avg=0.0; 7 cout << How many crab traps were set(1 to 10 only):; cin>>n; int a[n]; 9 10 for(int i-0i<n;i++) 12 13 14 15 16 for(int i-0;i<ni+) int j=i+1 ; cout<<please enter number of crabs trapped in <<j<< cin CrabCount; a[i]-CrabCount; avg=avg-a [1] ; //coutくくavgくくendl; 18 19 21 cout<<Avg is <<avg/n< <endl; int count e; 24 ▼ 25 if(alil(avg/n))t count count+1; 27 28 Get URL options compilation execution How many crab traps were set(1 to 10 only): 6 please enter number of crabs trapped in 1 11 please enter number of crabs trapped in 2 :99 please enter number of crabs trapped in 3 :77 please enter number of crabs trapped in 4 :44 please enter number of crabs trapped in 5 :98 please enter number of crabs trapped in 6 :46 Avg is 62.5 Total Number of pot catching above Avg is:3 Exit code: (normal program termination)

Add a comment
Know the answer?
Add Answer to:
You need to design a program to record data for a fishing boat. You will need...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You are a waterman daily plying the waters of Chesapeake Bay for blue crabs (Callinectes sapidus),...

    You are a waterman daily plying the waters of Chesapeake Bay for blue crabs (Callinectes sapidus), the best-tasting crustacean in the world. Crab populations and commercial catch rates are highly variable, but the fishery is under constant pressure from overfishing, habitat destruction, and pollution. These days, you tend to pull crab pots containing an average of 2.4 crabs per pot. Given that you are economically challenged as most commercial fishermen are, and have an expensive boat to pay off, you’re...

  • In C++ program Fishing Game Simulation   For this assignment, you will write a program that simulates a fishing game. In this game, a six-sided die is rolled to determine what the user has caught. Eac...

    In C++ program Fishing Game Simulation   For this assignment, you will write a program that simulates a fishing game. In this game, a six-sided die is rolled to determine what the user has caught. Each possible item is worth a certain number of fishing points. The points will not be displayed until the user has finished fishing, and then a message is displayed congratulating the user depending on the number of fishing points gained.   Here are some suggestions for the...

  • Average Rainfall Design a program that uses nested loops to collect data and calculate the average...

    Average Rainfall Design a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of...

  • Tasmanian abalone fishing boats, each costing $500,000, trawl the waters of Tasmania for abalone. The total...

    Tasmanian abalone fishing boats, each costing $500,000, trawl the waters of Tasmania for abalone. The total dollar value of abalone caught by the boats collectively varies with number of boats (N) and is Total $ Value (1000’s of $’s) = 1000N − N 2 This gives a marginal collective total value of the catch of Marginal $ Value (1000’s of $’s) = 1000 − 2N All boats are identical, so each boat has the same size and value of catch....

  • Design a program that uses nested loops to collect data and calculate the average rainfall over...

    Design a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterte twelve times, onece for each month. Each itertion of the inner loop will ask the user for the inches of rainfall for tht month. After all iterations, the program should display the number of months, the...

  • Small Basic Programming Question: Average Score- Write a program that uses loop to collect data and...

    Small Basic Programming Question: Average Score- Write a program that uses loop to collect data and calculate the average score over a number of tests for a number of students. The program should: 1. first ask the user to enter the number of students in the range of 1 to 10. 2. then the program asks the user to enter the number of tests (in the range of 1 to 5) 3. Then use a loop to collect the scores...

  • Small Basic Programming Question: Average score Write a program that uses loops to collect data and...

    Small Basic Programming Question: Average score Write a program that uses loops to collect data and calculate the average score over a number of tests for a number of students. The program should : 1. first ask the user to enter the number of students in the range of 1 to 10. 2. then the program asks the user to enter the number of tests (in the range of 1 to 5) 3. Then use a loop to collect the...

  • I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions...

    I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions only as (DieRoll, Guess, cnt1, cnt2) followed by this statement: srand((unsigned int)time (NULL)); which will give the random number generator a random starting point. Note: srand and rand require the TIME.H (or iomanip) cnt1 and cnt2 will be used in Chapter 5 drop box as counters for loops. Do NOT create additional variables. Points will be taken off for any additional variable creation. 2....

  • Write a program that writes a series of random numbers to a file. Each random number...

    Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500 inclusive. 1.Use a file called randoms.txt as a input file and output file a. If you go to open the file and its not there then ask the user to create the file     and then quit 2. Ask the user to specify how many random numbers the file will hold. a.Make sure that the...

  • C++ for this exercise, you will make a simple Dungeon Crawl game. For an enhanced version,...

    C++ for this exercise, you will make a simple Dungeon Crawl game. For an enhanced version, you can add monsters that randomly move around. Program Requirements While the program is an introduction to two-dimensional arrays, it is also a review of functions and input validation. check: Does the program compile and properly run? does all functions have prototypes? Are all functions commented? Is the program itself commented? Are constants used where appropriate? Are the required functions implemented? Is the dungeon...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT