help flag controlled loops

im not sure what to do with task 3 its suppose to take names and and points and arange them in smallest to largest with totals added up


//----------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>


using namespace std;

// name course exercise
const string NAME = "Cole Williams";
const string COURSE = "CST 113";
const string EXERCISE = " Exercise 7";
const int SCREEN_WIDTH = 80;
//task 2-----
const char sentinel = '#';
// end task 2---

int main(void)
{
//task 1 --------------------------------------------------------
int filename;
int count = 0;
int startvalue = 0;
//---------------------------------------------------------------
//Input file name
ifstream in;
ifstream in2;
in2.open("ex7task4.txt");
//output file name
ofstream out;
//Calling the needed files
out.open("ex7out.txt");

// Name Exersice Course
out << setw(50) << NAME << endl;
out << setw(47) << COURSE << endl;
out << setw(48) << EXERCISE << endl;

//Divider
out << setfill('*') << setw(SCREEN_WIDTH) << " " << setfill(' ') << endl;

cout << "Select an the input file: " << endl;
cout << "1. ex7-1.txt" << endl;
cout << "2. ex7-2.txt" << endl;
cout << "3. ex7-3.txt" << endl;
cout << "Enter the file name you want to open: ";
cin >> filename;
cout << setfill('*') << setw(SCREEN_WIDTH) << " " << setfill(' ') << endl;

//task 0----------------------------------------------------------------------
switch (filename)
{
case 1:
in.open("ex7-1.txt");
break;
case 2:
in.open("ex7-2.txt");
break;
case 3:
in.open("ex7-3.txt");
break;

default:
out << "This is not a valid input file number" << endl;

}



// task 1 counting while loop---------------------------------------------------------
out << "Task 1 counting while loop" << endl;

in >> startvalue;

out <<"The start value is: " << startvalue << endl;
while (count < 100)
{


out << setw(5) << startvalue;
count ++;
startvalue += 4;
if ( count % 10 == 0)
{
out << endl;
}





}
out << setfill('*') << setw(SCREEN_WIDTH) << " " << setfill(' ') << endl;

// end task 1 -----------------------------------------------------------------------
// start task 2 ---------------------------------------------------------------------
//task 2
char ch;
int acount;
int ecount;
int icount;
int ocount;
int ucount;
//end task 2
in.ignore(100,'\n');

in.get(ch);


ch=tolower(ch);

acount = 0;
ecount = 0;
icount = 0;
ocount = 0;
ucount = 0;

while(ch != sentinel)
{

if( ch == 'a')
{
acount++;
}



if ( ch == 'e')
{
ecount++;
}


if ( ch == 'i')
{
icount++;
}



if ( ch == 'o')
{
ocount++;
}


if ( ch == 'u')
{
ucount++;
}

out << ch;
in.get(ch);
ch=tolower(ch);


}
out << endl;
out << "How many A's there are in the joke " << acount << endl;
out << "How many E's there are in the joke " << ecount << endl;
out << "How many I's there are in the joke " << icount << endl;
out << "How many O's there are in the joke " << ocount << endl;
out << "How many U's there are in the joke " << ucount << endl;
out << setfill('*') << setw(SCREEN_WIDTH) << " " << setfill(' ') << endl;
in.ignore(100,'\n');
//end task 2 code---------------------------------------------------------------------
//start task 3 code-------------------------------------------------------------------
bool done;

int points;
int totalpoints;
string names;
done = true;
totalpoints = 0;

out << "Flag controlled loop" << endl;




while(!done)
{
getline(in, names);
in >> points;
in >> names;

if(points < 0)
{
done = false;
}
else
{


out << names << endl;

in >> points;
out << points << endl;


totalpoints += points;

}
out << totalpoints;

}














return 0;
}
Please use code tags ([code ] [/ code] without the spaces) and try to limit your code snippet to the parts you're having trouble with.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//start task 3 code-------------------------------------------------------------------
	bool done;

	int points;
	int totalpoints;
	string names;
	done = true;
	totalpoints = 0;

	out << "Flag controlled loop" << endl;

	
	

	while(!done)
	{
		getline(in, names);
		in >> points;
		in >> names;

		if(points < 0)
		{
			done = false;
		}
		else 
		{

	
		out << names << endl;

		in >> points;
		out << points << endl;
	

		totalpoints += points;
			
		}
		out << totalpoints;
		
	}














	return 0;
}
Topic archived. No new replies allowed.