{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

C++HW3 - fout<<"|" for star star> 0...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//Homework #3 //This program will calculate and illustrate the statisical values of fish caught in Maine lakes #include <iostream> #include <iomanip> #include <fstream> using namespace std; int main() { ofstream fout; fout.open( "Fishing.txt" ); int fish; //Fish caught in each lake int lakes = 0; //Number of Lakes fished in int max = 0; //Max number of fish caught in one lake int min; //Min number of fish caught in one lake double totalfish = 0; //Total number of fish caught double average; //Average number of fish caught cout << "How many fish were caught? (enter -1 to end data entry)" ; cin >> fish; fout << " \n\n" ; while (fish != -1) { int star = fish; //Number of stars to display per lake if (max <= fish) { max = fish; } else { } if (min >= fish) { min = fish; } else { }
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
lakes ++; totalfish = totalfish + fish;
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fout << "|" ; for ( star; star > 0; star--) //Displays start representing fish caught in each lake fout << "*" ; fout << endl; cin >> fish; } average = totalfish / lakes; fout << endl << setw(10) << "Number of values:" << setw (14) << lakes << endl; fout << setw(10) << setprecision (4) << "Average number of fish:" <<setw (8) << average << endl; fout << setw(10) << "Maximum number of fish:" <<setw (8) << max << endl; fout << setw(10) << "Minimum number of fish:" <<setw (8) << min << endl; fout.close(); return 0; } Steve Carr |********** |************ |*************** |***** Number of values: 4 Average number of fish: 10.5 Maximum number of fish: 15 Minimum number of fish: 5...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern