zandiago 115 Nearly a Posting Maven Featured Poster

Good day:
My infile contains the following:

U
Apple Pie
1.29
A
Bacon Burger
3.45
V
Burrito
2.09
S
Cheeseburger, Double
3.59
W
Cheeseburger, Regular
2.95
Y
Chicken Nuggets
1.87
H
Chicken Sandwich
3.33
C
Chili, Bowl
2.12
X
Chili Dog
2.29
N
Chocolate Milk
0.98
D
Coffee
1.09
R
Fries, Large
1.89
F
Fries, Small
1.19
Q
Hamburger
2.45
Z
Hot Dog
1.99
T
Onion Rings, Large
2.59
G
Onion Rings, Small
1.57
J
Peach Pie
1.29
I
Potato, Baked
1.47
P
Salad, Regular
3.69
K
Salad, Side
1.95
M
Shake, Large
1.98
B
Shake, Small
1.49
O
Soft Drink, Large
1.69
L
Soft Drink, Regular
1.49
E
Soft Drink, Small
1.06

The assignment:
You are familiar with computer-driven systems used by cashiers in fast food restaurants. In this
project, you will plan and write a program that will simulate such a point-of-sale device. Here's how
it will work.
When a customer orders, the cashier presses a key for each item ordered (WITHOUT PRESSING
<ENTER>). If more than one of the same item is ordered, the key is pressed an appropriate
number of times. As each key is pressed, the name of the item and its price are displayed on the
next available line on the monitor. Typically, a customer might order a sandwich, then fries or
onion rings and finally, a drink or dessert.
After the customer finishes ordering, a key is pressed to indicate that the …

zandiago 115 Nearly a Posting Maven Featured Poster

In keeping with the requirements of the program. I need to use the preceeding problem with the use of functions:
1 for reading
1 for evaluating
1 for displaying the count
1 for calcualting and displaying the word length average
1 for displaying the word evaluation
Please take a look at the following and see why i'm having problems:

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;
void run();
void show(int grandTotal, int numWords);
int eval (int numChars, int total);
int display (int total, string sentence);
int counter (int numWords);

int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
	float total = 0.0F;
	int numChars = 0;
	int value = 0;
	int grandTotal=0;	
			
	string sentence;
	

	cout<<"Words"<<setw(30)<<"Value"<<endl<<endl;
	voidrun()
	{

	while (getline(infile,sentence,'\n'))
	{	

	value = sentence.size();
        total=0;
						
	++numWords;
		
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':
	case 'a': 
		  {
              total += A; 
              ++numChars;
			   break;
			   			  
	       }
	case 'C': 
	case 'c':
		{
			total+= C;
			++numChars;
			break;
						
		}
	case 'D': 
	case 'd':
		{
			total+= D;
			++numChars;
			break;
								
		}
	case 'E': 
	case 'e':
		{
			total+= E;
			++numChars;
			break;
									
		}
	case …
zandiago 115 Nearly a Posting Maven Featured Poster

Thx Lerner, i've completed the assignment and it works perfectly, i'm now just trying to break it down into the following functions:
1 for reading
1 for evaluating
1 for displaying the count
1 for calcualting and displaying the word length average
1 for displaying the word evaluation

zandiago 115 Nearly a Posting Maven Featured Poster

Please post what you've tried so we can tell you where your error is. Welcome aboard

zandiago 115 Nearly a Posting Maven Featured Poster

Actually, if i shifted the printing lines into the while loop..it still shows zero as the answer and the line "The average word evaluation is" prints 50 times because it's inside the help. I'm having a problem with the average evaluation. Thx for your input.

zandiago 115 Nearly a Posting Maven Featured Poster

Ok guys...problem solved. Thx for all the input. i'll be posting my code soon, to see how i can break down this program into different programs and then repost it. I have to provide functions for the following:
1 for reading
1 for evaluating
1 for displaying the count
1 for calcualting and displaying the word length average
1 for displaying the word evaluation
Thx much for the assistance.

zandiago 115 Nearly a Posting Maven Featured Poster

tonykjose.....welcome aboard once more...system("pause"); it will pause a program before it exits.The system("cls");...is a call to the OS command line, "cls" is a command on some operating systems that clears the screen.

zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
    ifstream infile;
    ofstream outfile;

    infile.open ("Wordcalc.txt");
    outfile.open ("WOutput");

    const float A = (1*2.0);//value for letter A
    const float C = (3 - 20.4);
    const float D = ((4/12.0) *3.09);
    const float E = ((5/3.0)+5.0);
    const float L = ((12+17)*3.7/2.8)+3.17;
    const float N = (14 /4.2-6.12)*8.4;
    const float R = (18.0/2);
    const float S = ((19*3.0) + 7.0)/2.1;
    const float T = (20+10.18);
    int numWords = 0;//# of words
    float total = 0.0F;
    int numChars = 0;
    int value = 0;
    int grandTotal=0;    
            
    string sentence;

    cout<<"Words"<<setw(30)<<"Value"<<endl<<endl;

    while (getline(infile,sentence,'\n'))
    {    
        value = sentence.size();
        total=0;
                        
    ++numWords;
        
    for(int i = 0; i < sentence.size(); i++)    
    switch(sentence[i])
    {
    case 'A':
    case 'a': 
          {
              total += A; 
              ++numChars;
               break;
                             
           }
    case 'C': 
    case 'c':
        {
            total+= C;
            ++numChars;
            break;
                        
        }
    case 'D': 
    case 'd':
        {
            total+= D;
            ++numChars;
            break;
                                
        }
    case 'E': 
    case 'e':
        {
            total+= E;
            ++numChars;
            break;
                                    
        }
    case 'L': 
    case 'l':
        {
            total+= L;
            ++numChars;
            break;
                                    
        }
    case 'N':
    case 'n':
        {
            total+= N;
            ++numChars;
            break;
                                    
        }
    case 'R':
    case 'r':
        {
            total+= R;
            ++numChars;
            
            break;
                        
        }
    case 'S':
    case 's':
        {
            total+= S;
            ++numChars;
            
            break;
                                    
        }
    case 'T':
    case 't':
        {
            total+= T;
            ++numChars;
            break;        
        }
        default:
        {
            total+=0;
            ++numChars;
            break;
        }
    grandTotal += total;    
    }
    
    cout<<sentence<<setw(30)<<total<<endl;
    }
        

    cout<<"The average word length is : "<<(numChars/numWords)<<endl;
    cout<<"The total # of words from the infile : "<<numWords<<endl;
    cout<<"The average word evaluation is : "<<(total)<<endl;    
    
    
    
    infile.close();
    outfile.close();

    return 0;
}
zandiago 115 Nearly a Posting Maven Featured Poster

tonykjose-welcome aboard....however, if you don't know what the comands are for then you may want to read up about them.... But just for simplicity....setw(15) is one way of manipulating the output for formatting, to allow an even width(distance) between your output so it looks clean, such as a column. Your second question...the command to input characters from the file ???.... if you look in my file you'll see the comand (getline(infile,sentence,'\n'))...This website provides great tutorials about the two following questions above. If you have specific questions, please open your own thread and also take a look at our FAQ and forum rules. Happy coding..

zandiago 115 Nearly a Posting Maven Featured Poster

int total = 0;......i deleted that one, but i still have problems with the averages.

zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
	float total = 0.0F;
	int numChars = 0;
	int value = 0;
	int grandTotal=0;	
			
	string sentence;

	cout<<"Words"<<setw(30)<<"Value"<<endl<<endl;

	while (getline(infile,sentence,'\n'))
	{	
		value = sentence.size();
        total=0;
						
	++numWords;
		
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':
	case 'a': 
		  {
              total += A; 
              ++numChars;
			   break;
			   			  
	       }
	case 'C': 
	case 'c':
		{
			total+= C;
			++numChars;
			break;
						
		}
	case 'D': 
	case 'd':
		{
			total+= D;
			++numChars;
			break;
								
		}
	case 'E': 
	case 'e':
		{
			total+= E;
			++numChars;
			break;
									
		}
	case 'L': 
	case 'l':
		{
			total+= L;
			++numChars;
			break;
									
		}
	case 'N':
	case 'n':
		{
			total+= N;
			++numChars;
			break;
									
		}
	case 'R':
	case 'r':
		{
			total+= R;
			++numChars;
			
			break;
						
		}
	case 'S':
	case 's':
		{
			total+= S;
			++numChars;
			
			break;
									
		}
	case 'T':
	case 't':
		{
			total+= T;
			++numChars;
			break;		
		}
		default:
        {
            total+=0;
            ++numChars;
			break;
		}
	
	
	int total = 0;
	value = sentence.size();
	grandTotal += total;	
	}
	
	cout<<sentence<<setw(30)<<total<<endl;
	}
		

	cout<<"The average word length is : "<<(value/numWords)<<endl;
	cout<<"The total # of words from the infile : "<<numWords<<endl;
	cout<<"The average word evaluation is …
zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
	float total = 0.0F;
	int numChars = 0;
	int value = 0;
	int grandTotal=0;

	
			
	string sentence;

		

	while (getline(infile,sentence,'\n'))
	{		
						
	++numWords;
		
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':
	case 'a': 
		  {
              total += A; 
              ++numChars;
			   break;
			   			  
	       }
	case 'C': 
	case 'c':
		{
			total+= C;
			++numChars;
			break;
						
		}
	case 'D': 
	case 'd':
		{
			total+= D;
			++numChars;
			break;
								
		}
	case 'E': 
	case 'e':
		{
			total+= E;
			++numChars;
			break;
									
		}
	case 'L': 
	case 'l':
		{
			total+= L;
			++numChars;
			break;
									
		}
	case 'N':
	case 'n':
		{
			total+= N;
			++numChars;
			break;
									
		}
	case 'R':
	case 'r':
		{
			total+= R;
			++numChars;
			
			break;
						
		}
	case 'S':
	case 's':
		{
			total+= S;
			++numChars;
			
			break;
									
		}
	case 'T':
	case 't':
		{
			total+= T;
			++numChars;
			break;		
		}
		default:
        {
            total+=0;
            ++numChars;
			break;
		}
	
	int total = 0;
	value = sentence.size();
	grandTotal += total;	
	}
	}
	
	cout<<"Words"<<setw(30)<<"Value"<<endl<<endl;
	cout<<"The average word length is : "<<(value/numWords)<<endl;
	cout<<"The total # of words from the infile : "<<numWords<<endl;
	cout<<"The average word evaluation is : "<<(grandTotal/numWords)<<endl;	
	
	
	infile.close();
    outfile.close();
 
	return …
zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
	float total = 0.0F;
	int numChars = 0;
	
			
	string sentence;

	cout<<"Words"<<setw(30)<<"Value"<<endl<<endl;	

	while (getline(infile,sentence,'\n'))
	{		
						
	++numWords;
		
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':
	case 'a': 
		  {
              total += A; 
              ++numChars;
			   break;
			   			  
	       }
	case 'C': 
	case 'c':
		{
			total+= C;
			++numChars;
			break;
						
		}
	case 'D': 
	case 'd':
		{
			total+= D;
			++numChars;
			break;
								
		}
	case 'E': 
	case 'e':
		{
			total+= E;
			++numChars;
			break;
									
		}
	case 'L': 
	case 'l':
		{
			total+= L;
			++numChars;
			break;
									
		}
	case 'N':
	case 'n':
		{
			total+= N;
			++numChars;
			break;
									
		}
	case 'R':
	case 'r':
		{
			total+= R;
			++numChars;
			
			break;
						
		}
	case 'S':
	case 's':
		{
			total+= S;
			++numChars;
			
			break;
									
		}
	case 'T':
	case 't':
		{
			total+= T;
			++numChars;
			break;		
		}
		default:
        {
            total+=0;
            ++numChars;
			break;
         }

		
	}	
	int value = 0;
	int total = 0;
	value = sentence.size();
	cout<<"Words"<<setw(30)<<"Value"<<endl;
	int grandTotal=0;
	grandTotal += total;	
	}	
	cout<<"The average word length is : "<<(value/numWords)<<endl;
	cout<<"The total # of words from the infile : "<<numWords<<endl;
	cout<<"The average word evaluation is : "<<(grandTotal/numWords)<<endl;	
	
	infile.close();
    outfile.close(); …
zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
    ifstream infile;
    ofstream outfile;

    infile.open ("Wordcalc.txt");
    outfile.open ("WOutput");

    const float A = (1*2.0);//value for letter A
    const float C = (3 - 20.4);
    const float D = ((4/12.0) *3.09);
    const float E = ((5/3.0)+5.0);
    const float L = ((12+17)*3.7/2.8)+3.17;
    const float N = (14 /4.2-6.12)*8.4;
    const float R = (18.0/2);
    const float S = ((19*3.0) + 7.0)/2.1;
    const float T = (20+10.18);
    int numWords = 0;//# of words
    float total = 0.0F;
    int numChars = 0;
    int value = 0;//# character in individual word
            
    string sentence;

    cout<<"Words"<<setw(30)<<"Value"<<endl<<endl;    

    while (getline(infile,sentence,'\n'))
    {
        value = sentence.size();
        
                        
    ++numWords;
        
    for(int i = 0; i < sentence.size(); i++)    
    switch(sentence[i])
    {
    case 'A':
    case 'a': 
          {
              total += A; 
              ++numChars;
               break;
                             
           }
    case 'C': 
    case 'c':
        {
            total+= C;
            ++numChars;
            break;
                        
        }
    case 'D': 
    case 'd':
        {
            total+= D;
            ++numChars;
            break;
                                
        }
    case 'E': 
    case 'e':
        {
            total+= E;
            ++numChars;
            break;
                                    
        }
    case 'L': 
    case 'l':
        {
            total+= L;
            ++numChars;
            break;
                                    
        }
    case 'N':
    case 'n':
        {
            total+= N;
            ++numChars;
            break;
                                    
        }
    case 'R':
    case 'r':
        {
            total+= R;
            ++numChars;
            
            break;
                        
        }
    case 'S':
    case 's':
        {
            total+= S;
            ++numChars;
            
            break;
                                    
        }
    case 'T':
    case 't':
        {
            total+= T;
            ++numChars;
            
            break;        
        }
        
    }
    cout<<sentence<<setw(30)<<showpoint<<total<<endl;
    }
    total = 0;
        
    cout<<"The average word length is : "<<(value/numWords)<<endl;
    cout<<"The total # of words from the infile : "<<numWords<<endl;
    cout<<"The average word evaluation is : "<<(total/numWords)<<endl;
    
    infile.close();
    outfile.close();

    return 0;
}

My outfile:

Words                         Value …
zandiago 115 Nearly a Posting Maven Featured Poster

I've tried placed the reset in around in the code, and it reverts back to the above, or it shows zero for everything. Thx for your input

zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
	float total = 0.0F;
	int numChars = 0;
	int value = 0;//# character in individual word
			
	string sentence;

	cout<<"Words"<<setw(30)<<"Value"<<endl<<endl;	

	while (getline(infile,sentence,'\n'))
	{
		value = sentence.size();
		cout<<sentence<<setw(30)<<showpoint<<total<<endl;
						
	++numWords;
		
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':case 'a': 
		  {
              total += A; 
              ++numChars;
			   break;
			   			  
	       }
	case 'C': case 'c':
		{
			total+= C;
			++numChars;
			break;
						
		}
	case 'D': case 'd':
		{
			total+= D;
			++numChars;
			break;
								
		}
	case 'E': case 'e':
		{
			total+= E;
			++numChars;
			break;
									
		}
	case 'L': case 'l':
		{
			total+= L;
			++numChars;
			break;
									
		}
	case 'N':case 'n':
		{
			total+= N;
			++numChars;
			break;
									
		}
	case 'R':case 'r':
		{
			total+= R;
			++numChars;
			break;
						
		}
	case 'S':case 's':
		{
			total+= S;
			++numChars;
			break;
									
		}
	case 'T':case 't':
		{
			total+= T;
			++numChars;
			break;
			
		}
	}
	
	}
	
	cout<<"The average word length is : "<<(numWords/value)<<endl;
	cout<<"The total # of words from the infile : "<<numWords<<endl;
	cout<<"The average word evaluation is : "<<(total/numWords)<<endl;
	
	infile.close();
    outfile.close();
 
	return 0;
}

Would the reset occur for every case statement? Additionally, if it were reset, …

zandiago 115 Nearly a Posting Maven Featured Poster

Please post the code of what you've already come up with.

zandiago 115 Nearly a Posting Maven Featured Poster

Thx for your input.How do you reset the total score for the word to zero?

zandiago 115 Nearly a Posting Maven Featured Poster

Good catch...just to emphasise.
example:

12/58 = 0

(integer arithmetic drops the fractional part). Welcome aboard too.

zandiago 115 Nearly a Posting Maven Featured Poster

consider this:

int count = 0;
int min = 32767;
for (i=0;i<count;i++)
{
if (number[count]<min)
min = number[count];
}//end of i
cout<<"Minimum # is"<<min<<endl;
zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
	float total = 0.0F;
	int numChars = 0;
	int value = 0;//# character in individual word
			
	string sentence;

	cout<<"Words"<<setw(30)<<"Value"<<endl<<endl;	

	while (getline(infile,sentence,'\n'))
	{
		value = sentence.size();
		cout<<sentence<<setw(30)<<showpoint<<total<<endl;
		cout<<value<<endl;
				
	++numWords;
		
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':case 'a': 
		  {
              total += A; 
              ++numChars;
			   break;
			  
	       }
	case 'C': case 'c':
		{
			total+= C;
			++numChars;
			break;
			
			
		}
	case 'D': case 'd':
		{
			total+= D;
			++numChars;
			break;
						
		}
	case 'E': case 'e':
		{
			total+= E;
			++numChars;
			break;
						
		}
	case 'L': case 'l':
		{
			total+= L;
			++numChars;
			break;
						
		}
	case 'N':case 'n':
		{
			total+= N;
			++numChars;
			break;
						
		}
	case 'R':case 'r':
		{
			total+= R;
			++numChars;
			break;
			
		}
	case 'S':case 's':
		{
			total+= S;
			++numChars;
			break;
						
		}
	case 'T':case 't':
		{
			total+= T;
			++numChars;
			break;					
		}
	}
	}
	cout<<"The average word length is : "<<endl;
	cout<<"The total # of words from the infile : "<<numWords<<endl;
	cout<<"The average word evaluation is : "<<(total/numWords)<<endl;
	
	infile.close();
    outfile.close();
 
	return 0;
}

Thx for your input. reset the total score for the word to …

zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
	float total = 0.0F;
	int numChars = 0;
	int value = 0;//# character in individual word
			
	string sentence;

	cout<<"Words"<<setw(30)<<"Value"<<endl<<endl;	

	while (getline(infile,sentence))
	{
		value = sentence.size();
				
	++numWords;
		
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':case 'a': 
		  {
              total += A; 
              ++numChars;
			   break;
			  
	       }
	case 'C': case 'c':
		{
			total+= C;
			++numChars;
			break;
			
			
		}
	case 'D': case 'd':
		{
			total+= D;
			++numChars;
			break;
						
		}
	case 'E': case 'e':
		{
			total+= E;
			++numChars;
			break;
						
		}
	case 'L': case 'l':
		{
			total+= L;
			++numChars;
			break;
						
		}
	case 'N':case 'n':
		{
			total+= N;
			++numChars;
			break;
						
		}
	case 'R':case 'r':
		{
			total+= R;
			++numChars;
			break;
			
		}
	case 'S':case 's':
		{
			total+= S;
			++numChars;
			break;
						
		}
	case 'T':case 't':
		{
			total+= T;
			++numChars;
			break;					
		}
	}
	}
	

	cout<<sentence<<setw(30)<<total<<endl;
	cout<<"The average word length is : "<<value<<endl;
	cout<<"The total # of words from the infile : "<<numWords<<endl;
	cout<<"The average word evaluation is : "<<(total/numWords)<<endl;
	cout<<value<<endl;
	

	infile.close();
    outfile.close();

	

 
	return 0;
}

The thing is it shows the value for all 58 words in …

zandiago 115 Nearly a Posting Maven Featured Poster

Ok, problem solved. Thanks again, time to move on to my next thread. see you around.

zandiago 115 Nearly a Posting Maven Featured Poster

Brown's method:

Two numbers are entered in from the keyboard. If the
larger number is odd, the smaller number is added to an accumulator. Then the larger number
is integer divided by two and the smaller number is doubled. Again if the larger number's
division is odd, the smaller number's doubling is added to an accumulator. lf the larger number
is even, nothing is added to the accumulator. This is repeated until the large number
sequence equals zero. The accumulator now holds the multiplication answer.
Write a program using functions, that will accomplish this task. Repeat until the user wishes to stop.
lt is not necessary to display the accumulation work as shown in the examples.
Output is to the screen and printer and should look like:
Your Name Class # Date & Time
XXXX times XXXX by conventional math = XXXXXXX
XXXX times XXXX by Zoo's method = XXXXXXX
Example 1) 75 x 23 = 1725
Larger 			Smaller 			Add to Accumulator
75			 23 				23
37 			46 				46
18 			92 				O
9 			184 				184
4 			368				 O
2 			736 				O
1 			1472 				1472
1725(TOTAL & PRODUCT)


Example 2) 
122 x 251 = 30622
Larger 		Smaller 			Add to Accumulator
251 		122 					122
125 		244 					244
62 		488 					O
31 		976 					976
15 		1952 					1952
7 		3904 					3904
3 		7808 					7808
1 		15616					 15616
30622(TOTAL & PRODUCT)
zandiago 115 Nearly a Posting Maven Featured Poster

Ptolemy-welcome aboard and thanks for your input. The program doesn't work wen using "Brown's method". It actually shows the last #, that the user entered. I think there may be something wrong with my process function.

zandiago 115 Nearly a Posting Maven Featured Poster

I had modified the program a bit:

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;

void run();
int process(int larger, int smaller);
bool isOdd(int number);

int main()
{
    char again = 'y';

    cout << "Would you like to run again (yes/no)?" <<endl;
    cin >> again;
    while (again=='y')

    {
void run()
{
    int numA, numB, x, result;
    cout<<"Your two numbers to multiply are?"<<endl;
    cin>>numA>>numB;

    if (numB>numA)
    {
    x=numA;
    numA=numB;
    numB=x;
    }

    result = process( numA, numB);

    cout << "Zan Diago  Oct 24, 2007 2:30pm\n";
    cout << numA << " times " << numB<< " by conventional math = " << (numA * numB) <<endl;
    cout << numA << " times " << numB<< " by Brown's method = " << result <<endl;
}

    
    int process( int larger, int smaller ) 
    {
    int result=0;
    if (larger%2==0) 
    {
        result+=smaller;
        smaller*=2;
        larger/=2;
    }
    return result;
        
    }


    bool isOdd( int number ) 
    {  
        if ((number % 2) == 1) return true;  
        else
            return false;  
    }
    }

Any help is appreciated. As of now, the program only prints out :"Go again?".

zandiago 115 Nearly a Posting Maven Featured Poster

Ptolemy - welcome aboard and good catch. If there is an additional or a difference is brace count, then that's the error message that the compiler will display.

zandiago 115 Nearly a Posting Maven Featured Poster

A brief description of the assignment would also be helpful

zandiago 115 Nearly a Posting Maven Featured Poster

Thanks for your input AD, here goes my revised code, howver, as of now the calcualtions are wrong and the output shows the value(which is wrong) and then the name:

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
	float total = 0.0F;
	int numChars = 0;
			
	string sentence;
	while (infile>>sentence)
	{
		cout<<sentence<<endl;
		cout<<total;
		
	++numWords;
	
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':case 'a': 
		  {
              total += A; 
              ++numChars;
			  break;
			  
	       }
	case 'C': case 'c':
		{
			total+= C;
			++numChars;
			break;
			
			
		}
	case 'D': case 'd':
		{
			total+= D;
			++numChars;
			break;
						
		}
	case 'E': case 'e':
		{
			total+= E;
			++numChars;
			break;
						
		}
	case 'L': case 'l':
		{
			total+= L;
			++numChars;
			break;
						
		}
	case 'N':case 'n':
		{
			total+= N;
			++numChars;
			break;
						
		}
	case 'R':case 'r':
		{
			total+= R;
			++numChars;
			break;
			
		}
	case 'S':case 's':
		{
			total+= S;
			++numChars;
			break;
						
		}
	case 'T':case 't':
		{
			total+= T;
			++numChars;
			break;					
		}
	}
	}
	int sentlength = sentence.length();//number of individual characters

	cout<<"Words"<<setw(20)<<"Value"<<endl;
	cout<<"The average word length is : "<<sentlength<<endl;
	cout<<"The total # of words from the infile …
zandiago 115 Nearly a Posting Maven Featured Poster

Oh goodness, forgot all about that 'cout' statement. But then i couldn't 'cout' the value, because it has to go through the switch statements to carry out the calculations?

zandiago 115 Nearly a Posting Maven Featured Poster

I also tried putting in my inline code, and still shows without the line #'s like how AD had edit it.

zandiago 115 Nearly a Posting Maven Featured Poster
#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
	float total = 0.0F;
	int numChars = 0;
			
	string sentence;
	while (infile>>sentence)
	{
	++numWords;
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':case 'a': 
		  {
              total += A; 
              ++numChars;
			  break;
			  
	       }
	case 'C': case 'c':
		{
			total+= C;
			++numChars;
			break;
			
			
		}
	case 'D': case 'd':
		{
			total+= D;
			++numChars;
			break;
						
		}
	case 'E': case 'e':
		{
			total+= E;
			++numChars;
			break;
						
		}
	case 'L': case 'l':
		{
			total+= L;
			++numChars;
			break;
						
		}
	case 'N':case 'n':
		{
			total+= N;
			++numChars;
			break;
						
		}
	case 'R':case 'r':
		{
			total+= R;
			++numChars;
			break;
			
		}
	case 'S':case 's':
		{
			total+= S;
			++numChars;
			break;
						
		}
	case 'T':case 't':
		{
			total+= T;
			++numChars;
			break;					
		}
	}
	}
	int sentlength = sentence.length();//number of individual characters

	cout<<"Words"<<setw(20)<<"Value"<<endl;
	cout<<sentence<<setw(15)<<total<<endl;
	cout<<"The average word length is : "<<sentlength<<endl;
	cout<<"The total # of words from the infile : "<<numWords<<endl;
	cout<<"The average word evaluation is : "<<(total/numWords)<<endl;
	

	infile.close();
    outfile.close();

	

 
	return 0;
}

Thanks for the assitance. I've got a bit of issue with the infile. A few things:

zandiago 115 Nearly a Posting Maven Featured Poster

maybe just a silly question...but if sentence is only the value of the last word read from the file, why in my previos post did it print '0' as the average length and the value as being 1663.71?

zandiago 115 Nearly a Posting Maven Featured Poster

I'm also going to see how the program can be broken down into the following functions:
1 for reading
1 for evaluating
1 for displaying the count
1 for calcualting and displaying the word length average
1 for displaying the word evaluation

zandiago 115 Nearly a Posting Maven Featured Poster

Thanks, a quick observation though, look at this code:

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
	float total = 0.0F;
	int numChars = 0;
		
	string sentence = "Cotton";
	{
	++numWords;
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':case 'a': 
		  {
              total += A; 
              ++numChars;
			  break;
			  
	       }
	case 'C': case 'c':
		{
			total+= C;
			++numChars;
			break;
			
			
		}
	case 'D': case 'd':
		{
			total+= D;
			++numChars;
			break;
						
		}
	case 'E': case 'e':
		{
			total+= E;
			++numChars;
			break;
						
		}
	case 'L': case 'l':
		{
			total+= L;
			++numChars;
			break;
						
		}
	case 'N':case 'n':
		{
			total+= N;
			++numChars;
			break;
						
		}
	case 'R':case 'r':
		{
			total+= R;
			++numChars;
			break;
			
		}
	case 'S':case 's':
		{
			total+= S;
			++numChars;
			break;
						
		}
	case 'T':case 't':
		{
			total+= T;
			++numChars;
			break;					
		}
	}
	}

	cout<<"Words"<<setw(20)<<"Value"<<endl;
	cout<<sentence<<setw(15)<<total<<endl;
	cout<<"The average word length is : "<<sentence.size()/numWords<<endl;
	cout<<"The total # of words from the infile : "<<numWords<<endl;
	cout<<"The average word evaluation is : "<<(total/numWords)<<endl;
	

	infile.close();
    outfile.close();

	

 
	return 0;
}

The output comes like this:

Words               Value
Cotton         19.552
The average word length is …
zandiago 115 Nearly a Posting Maven Featured Poster

Thanks for your input AD. I'm just now trying to displaying the count of words (from infile), calcualting and dis playing the word length average and displaying the word evaluation average. Here is what i've tried:

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	int numWords = 0;//# of words
		
	string sentence;
	while (!infile.eof())
	{
	float total = 0.0F;
	int numChars = 0;
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
	case 'A':case 'a': 
		  {
              total += A; 
              ++numChars;
			  break;
			  numWords+=numWords;
	       }
	case 'C': case 'c':
		{
			total+= C;
			++numChars;
			break;
			numWords+=numWords;
			
		}
	case 'D': case 'd':
		{
			total+= D;
			++numChars;
			break;
			numWords+=numWords;
			
		}
	case 'E': case 'e':
		{
			total+= E;
			++numChars;
			break;
			numWords+=numWords;
			
		}
	case 'L': case 'l':
		{
			total+= L;
			++numChars;
			break;
			numWords+=numWords;
			
		}
	case 'N':case 'n':
		{
			total+= N;
			++numChars;
			break;
			numWords+=numWords;
			
		}
	case 'R':case 'r':
		{
			total+= R;
			++numChars;
			break;
			numWords+=numWords;

		}
	case 'S':case 's':
		{
			total+= S;
			++numChars;
			break;
			numWords+=numWords;
			
		}
	case 'T':case 't':
		{
			total+= T;
			++numChars;
			break;
			numWords+=numWords;
			
		}
	}
	}

	cout<<"Words"<<setw(15)<<"Value"<<endl;
	cout<<sentence<<setw(15)<<total<<setw(5)<<endl;
	cout<<"The average word length is : "<<sentence.size()/numWords<<endl;
	cout<<"The total …
zandiago 115 Nearly a Posting Maven Featured Poster

Ok, so how do i now calculate the average length of the word and also the average of the evaluation? In this case i only have one word, however, in my infile, i have like 60 words, that i'll need to find the average of.

zandiago 115 Nearly a Posting Maven Featured Poster

Duoas-thank you very much for your input, and forgive me for not officially welcoming you to the forum earlier. Thx again for your inout, i'll be reposting in a few. Thx again.

zandiago 115 Nearly a Posting Maven Featured Poster

Good day. Thanks for your input, I've revised my code. I however, do get the wrong total for the word COTTON, that I have as an example, please be a second pair of eyes for me. I've changed the switch statements up. The answer i get in 78, when i try "Cotton", however, when I use them all caps, (i.e."COTTON"), i get a value of 178. The infile will contain a mixture of upper and lower case letters. How can i address that. Neither of those answers above is correct. The answer should be 19.552. In the example above, using the word cotton, there are no O's in my statements, so i'm assuming that it will assign those letters a zero. Thanks for the input.

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
		
	string sentence = "COTTON";
	float total = 0.0F;
	int numChars = 0;
	for(int i = 0; i < sentence.size(); i++)	
    switch(sentence[i])
    {
      case 'A': 
		  {
              total += A; 
              ++numChars;
	       }
	case 'C':
		{
			total+= C;
			++numChars;
			
		}
	case 'D':
		{
			total+= D;
			++numChars;
			
		}
	case 'E':
		{
			total+= …
zandiago 115 Nearly a Posting Maven Featured Poster

Your input is appreciated. As required by my professor, i had taken your advice. I've revised my code with the use of functions...it doesn't work..this is where i'm stuck.here goes:

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	int numA=0;
	int numB=0;
	int productB;
	int accumulator = 0;

	void(getinput)
	{
	cout<<"Your two numbers to multiply are?"<<endl;
	cin>>numA>>numB;
	}

	void (IsLarger)
	{
		{
		if (numA>numB)
		numA==larger;
	}
		else numA==smaller;
		}


	void(IsOdd)
	{
		while (larger%2==1)
		accumulator+=smaller;//how to add the smallest # to the accumulator???
	}

	void (processdata)
	{	
		{
		 (larger/2)(smaller*2)
		


	}


	int productA = (numA * numB);
	cout<<numA<<" times "<<numB<<" by conventional math = "<<productA<<endl;
	cout<<numA<<" times "<<numB<<" by Brown's method = "<<productB<<endl;
	

	return 0;
}

I'm not sure on how to carry out this part of the assignment:
If the larger number is odd, the smaller number is added to an accumulator. Then the larger number is integer divided by two and the smaller number is doubled. Again if the larger number's division is odd, the smaller number's doubling is added to an accumulator. lf the larger number is even, nothing is added to the accumulator. This is repeated until the large number sequence equals zero.
Thanks for your assistance.

zandiago 115 Nearly a Posting Maven Featured Poster

This is what I've got so far:

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	double numA=0;
	double numB=0;
	double productB;
	double accumulator = 0;
	cout<<"Your two numbers to multiply are?"<<endl;
	cin>>numA>>numB;

	double productA = (numA * numB);

	if (numA>numB||numA%2==1)//check if larger and odd???
	{
		accumulator+=accumulator;//how to add the smallest # to the accumulator???
	}
	then (numA/2) + (2*numB);//something to make the program continue
	{
		accumulator+=accumulator;//if the larger number's
division is odd, the smaller number's doubling is added to an accumulator
	}//after all this assign the value to productB

Any assistance is appreciated.	
	cout<<numA<<" times "<<numB<<" by conventional math = "<<productA<<endl;
	cout<<numA<<" times "<<numB<<" by Brown's method = "<<productB<<endl;
	

	return 0;
}

The assignment is as follows:
Program "multiplication"
With too much time on his hands, Professor Brown has devised a new system of multiplication
called the "half and double" method. Two numbers are entered in from the keyboard. If the
larger number is odd, the smaller number is added to an accumulator. Then the larger number
is integer divided by two and the smaller number is doubled. Again if the larger number's
division is odd, the smaller number's doubling is added to an accumulator. lf the larger number
is even, nothing is added to the accumulator. This is repeated until the large number
sequence equals zero. The accumulator now holds the multiplication answer.
Write a program using functions, that will accomplish this task. …

zandiago 115 Nearly a Posting Maven Featured Poster

Ok AD, thx for the jump start. So in my specific case would be something like this:

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
	ifstream infile;
    ofstream outfile;

	infile.open ("Wordcalc.txt");
	outfile.open ("WOutput");

	const float A = (1*2.0);//value for letter A
	const float C = (3 - 20.4);
	const float D = ((4/12.0) *3.09);
	const float E = ((5/3.0)+5.0);
	const float L = ((12+17)*3.7/2.8)+3.17;
	const float N = (14 /4.2-6.12)*8.4;
	const float R = (18.0/2);
	const float S = ((19*3.0) + 7.0)/2.1;
	const float T = (20+10.18);
	
	string sentence = "How Now Brown Cow.";
	float total = 0.0F;
	int numChars = 0;
	for(int i = 0; i < sentence.size(); i++)
	{
    switch(sentence[i])
    {
      case 'A': 
              total += A; 
              ++numChars; 
              break;
			  cout<<sentence<<total<<numChars<<endl;
	}
	}
			  

	cout<<"Words"<<setw(15)<<"Value"<<endl;
	cout<<sentence<<setw(15)<<total<<numChars<<endl;
	cout<<"The average word length is : "<<endl;
	cout<<"The average word evaluation is : "<<endl;

	infile.close();
    outfile.close();

 
	return 0;
}

I had tried above with your example, but with no results. Do i need any additional headers? Thx for the input.

zandiago 115 Nearly a Posting Maven Featured Poster

So far this is what I have:

#include <iomanip>
#include <cmath>
#include <fstream>
#include<string>
#include<iostream>

using namespace std;


int main()
{
    ifstream infile;
    ofstream outfile;

    infile.open ("Wordcalc.txt");
    outfile.open ("WOutput");

    char A = (1*2.0);//value for letter A
    char C = (3 - 20.4);
    char D = ((4/12.0) *3.09);
    char E = ((5/3.0)+5.0);
    char L = ((12+17)*3.7/2.8)+3.17;
    char N = (14 /4.2-6.12)*8.4;
    char R = (18.0/2);
    char S = ((19*3.0) + 7.0)/2.1;
    char T = (20+10.18);

    string names;
    double wordlength = 0;
    double wordeval = 0;
    double value = 0;
    while (infile>>names)
    {



    cout<<"Words"<<setw(15)<<"Value"<<endl;
    cout<<names<<setw(15)<<value<<endl;
    cout<<"The average word length is : "<<wordlength<<endl;
    cout<<"The average word evaluation is : "<<wordeval<<endl;

    }
      infile.close();
      outfile.close();


    return 0;
}

The assignment:
This program, which must use functions and parameter passing, reads in a list of single
words from a sequential file called "a:\wordcalc.txt". It calculates a word value based upon
formulae for individual selected letters in the word (explained below). The program displays
each word along with its calculated word value. lt then displays a count of the total words,
the average word length and the average word evaluation.
The letter evaluations are based upon the ORDINAL position ofthe CAPITAL letter in the
alphabet (examples: A = 1; B = 2; C = 3; Y = 25; Z = 26). The following are the formulae for
(all other letters have a value of zero):
A ==>ordinal value * 2.0
C ==>ordinal value - 20.4

zandiago 115 Nearly a Posting Maven Featured Poster

Even after so long after watching this stuff im still laughing...i even forgot how to do a simple C++ assignment. I laughed out all my knowledge...i don't even know what a C++ array is.....

zandiago 115 Nearly a Posting Maven Featured Poster

I know m8. I guess we've got the new michael jackson and young bret lee

zandiago 115 Nearly a Posting Maven Featured Poster

This is a great environment for Prom:
http://www.youtube.com/watch?v=TtJRNyPK-lc

zandiago 115 Nearly a Posting Maven Featured Poster
zandiago 115 Nearly a Posting Maven Featured Poster

So do u want to limit the number of inputs that that the user can do? You can choose either option.

zandiago 115 Nearly a Posting Maven Featured Poster

I have a quick thought. Many persons who join the forums are usually students who are required to take a course, for example C++. After the student has completed their course and have received the help from the forum, many never return here. So the inactive accounts/profiles...pretty much just hang around..

zandiago 115 Nearly a Posting Maven Featured Poster

Ok, since you haven't completed arrays yet, try something like this:

cout<<"Max of 2 and 1 is: "<<max(2,1)<<endl;
cout<<max<<endl:

The above max function should print(cout) 2. A link that you wanna keep in mind(will help you later on) is: http://msdn2.microsoft.com/en-us/library/wh15hsex(VS.71).aspx.
Another way to see your highest valie from a range done:

#include <iostream>

using namespace std;

int main()
{
    
    const int MAX_NUM_INTEGERS = 10;
    long int integers[10];
    long int i = 0, maximumValue = 0;

    cout << "Please enter 10 integers : \n\n";

    while ( i < MAX_NUM_INTEGERS)
    {
        cin >> integers[i];
        i++;
    
        if (integers[i - 1] > maximumValue)
        {
            maximumValue = integers[i-1];
        }
    }

    cout << "\nThe largest number you have entered is " << maximumValue << "\n\n";

    system("pause");
    return 0;
}

See if you can find out whats going on-that program above required user input of 10 integers and find the maxinum of the numbers. See how you can adopt it to your specific program.[vietbong87]