Welcome! Log In Create A New Profile

Advanced

Catch Up assignment

Posted by silva_surfa 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Catch Up assignment
August 13, 2006 03:33PM
smiling bouncing smiley

This is a basic idea :

Change variables!!

#include <iostream>
#include <string>
using namespace std;
const int N = 20;
// determines number of upper case and lower case words and deternmining
// sum of all of them
int determineNumberUpAndLow (string sent, int a[N][2],int sumU,int sumL)
{ int i,j;
int length,Upcount,Lcount;
cout << "Enter in a sentence: ";
getline(cin, sent, '\n'winking smiley;
length=sent.size();
Upcount=0;
Lcount=0;
sumU = 0;
sumL = 0;
cout<<"the length is " <<length;
// initialise all elements in array to 0
for (int i = 0;i <= length; i++)
{ for (int j = 0;j <= length; j++)
a[j] = 0;
}
// main test operation
for (int i = 0;i <= length; i++)
{
if ((sent == 'A'winking smiley || (sent== 'E'winking smiley || (sent== 'I'winking smiley || (sent== 'O'winking smiley || (sent)=='U'winking smiley
{ (Upcount=Upcount+1);
a[1] = Upcount;
sumU = a[1] + sumU;
}
if ((sent == 'a'winking smiley || (sent== 'e'winking smiley || (sent== 'i'winking smiley || (sent== 'o'winking smiley || (sent)=='u'winking smiley
{ (Lcount=Lcount+1);
a[2] = Lcount;
sumL = a[2] + sumL;
}
}
/*for (int i = 0;i <= length; i++) ---> to test contents of array a

{ for (int j = 0;j <= length; j++)
{ cout<<a[j];
}
cout<<endl;
}*/

cout<<"sumU is "<<sumU<<" sumL is "<<sumL<<endl;
cout<<"number of upper case vowels"<<Upcount<<endl;
cout<<"number of lower case vowels"<<Lcount<<endl;
} // determineNumberUpAndLow

// Calculates average of Upper case and lower case words
int CalculateTwoAverages(string s,int b[N][2],int sum,int sum2)
{ int i,j,avg,avg2,length;
length=s.size();
for (int i = 0;i <= length; i++)
{ avg = sum % length;
avg2= sum2% length;
}
cout << "The first average is " <<avg<< "and the 2nd one is "<<avg2<<endl;
} // CalculateTwoAverages

int main() {
string sen;
int times[N][2];
int sumUp,sumLow;
while (sen != 'END'winking smiley || (sen != 'end'winking smiley do
{ determineNumberUpAndLow(sen,times,sumUp,sumLow);
CalculateTwoAverages(sen,times,sumUp,sumLow);
}
cout<<endl;
}// main




Sorry, only registered users may post in this forum.

Click here to login