Programming 101- Challenge 7

Hello~!

Yes it has been a very, very, long time since I posted anything programming wise. I have been really busy with University trying to get all my portfolio work done and handed in on time, it was very stressful!

Well, enough about me and onto the programming! I decided to share with you challenge 7 from my portfolio with you today as it was one of the many interesting and probably most random challenges we had to do.

The task:

Write a program which asks the user to write some text before analysing it to see how many occurrences of each vowel appears in that text, you should store the number of occurrences of each vowel in an array of size 5.

Adapt this program to produce some more statistics about the text, this may include some or all of the following…

 

  • The vowel that occurs most/least often
  • The average (mean) number of occurrences for the vowels
  • A list of vowels, ordered by number of occurrences
  • You could even use the Cursor and Colour controllers to draw a histogram!

Here is my code!

<<——————————->>

//

//  challenge 7.cpp

//  

//

//  Created by Sarah Oluyede on 30/03/2012.

//  Copyright (c) 2012_All rights reserved.

//

#include <iostream>

#include <string>

using namespace std;

int main()

{

    string text;

    int vowels[5] = {0,0,0,0,0}; 

    char vvowels[5] = {‘a’, ‘e’, ‘i’, ‘o’, ‘u’};

    int strlen; 

    cout << “Enter the text you want to analyse” << endl << endl;

    getline(cin, text);

    cout << endl << “Analysing \”" << text << “\” … ” << endl << endl;

    cout << “Analysis Result” << endl << “——————————” << endl << endl;

    strlen = text.length();

    cout << “\tText Length : “<< strlen << endl << endl;

    for(int i=0; i<5; i++){

        for(int n=0; n<strlen; n++){

            if (text[n] == vvowels[i]){

                vowels[i] += 1;

            }   

        }

    }

    for(int i=0; i<5; i++){

        cout << “\tNumber of Vowel \”" << vvowels[i] << “\” : “<< vowels[i] << endl << endl;

    }

    double total = vowels[0] + vowels[1] + vowels[2] + vowels[3] + vowels[4];

    cout << “\tTotal Number of Vowels \”a + e + i + o + u\” : “<< total << endl << endl;

    int moccur = 0;

    for(int i = 0; i < 5; i++){

        if(vowels[i] > moccur){

            moccur = i;

        }else{

            moccur = moccur;

        }

    }

    cout << “\tMost Occured Vowel \”" << vvowels[moccur] << “\” : “<< vowels[moccur] << endl << endl;

    int loccur = 0;

    for(int i = 0; i < 5; i++){

        if(vowels[i] < loccur){

            loccur = i;

        }else{

            loccur = loccur;

        }

    }

    cout << “\tLeast Occured Vowel \”" << vvowels[loccur] << “\” : “<< vowels[loccur] << endl << endl;

    double mean;

    mean = total / 5;

    cout << “\tThe mean number of occurences of vowels is : ” << mean << endl << endl;

    return 0;

}

<<——————————->>

You should try it out, it’s pretty fun to play with!

App of Interest: Instagram

Hello!

I have a lot of interests and I thought I could share some with you! My posts will vary in topic and genre and If you feel there is something I should have a look at or try please feel free to let me know and drop me a little comment below, I will definitely try it out and post my thoughts on it.

Today it’s going to be an app that I have recently enjoyed using and also would encourage you to use as well and that app is: Instagram.

This easy to use app allows anyone to take beautiful pictures without the skills of a professional photographer. I had heard about this application for a long time but I really had no interest in it till I bought my 32GB iPod Touch; from that day, my perspective of the word changed.

Taking professional looking picture has never been so easy! it’s really simply to use and easy to set up too, you’ll be surprised at the pictures some users have taken with Instagram.

Here are a few pictures I’ve personally taken:

The set-up is quick and simple and you have the option of making your picture public or private. followers can like and comment on an image and popular images appear on the popular page. There are no limits on the number of pictures you can take so you can truly spread your wings!

You can find me on instagram @sarah_i_oluyede, hope to see there soon! :D

Programming 101- Challenge 12

In my programming class I was recently given a the following challenge:

“Make some classes to which display shapes or graphical ‘sprites’ on the screen: good options might be squares, rectangles, staircases, stick men or perhaps even characters from the remarkable ASCII Star Wars (which may be found by opening a command prompt and entering “telnet towel.blinkenlights.nl”).”

I have to admit I was stumped for a while but with a bit of guidance I managed to complete it! The program prints the character ‘H’ to produce a flight of stairs with 20 steps, the code is below:

<<——————————->>

#include <iostream>
#include “110ct.h”

using namespace std;

class DisplayStairs
{
int Stairs;
char letter;
public:
DisplayStairs(){};
void Display(char letter, int Stair);

};
void DisplayStairs::Display(char letter, int Stair)
{
for (int i = 1; i <= Stair; i++)
{
for (int j = 1; j <= i; j++)
{
cout << letter;
}
cout << endl;
}
}

int main()
{
DisplayStairs s;
s.Display(‘H’, 20);
qin.get();
return 0;
}

<<——————————->>

It was really rewarding to see this program work and I was able to change the character and the number of steps printed, I quite like it like this however.

 

Hello Future…

Hello!
My name is Sarah, I’m 19 and I’m a First Year Computing Student at Coventry University, I also take a Module in Japanese. At the moment I am learning C++ and I hope to fully understand it and be able to use it to its full potential at the end of the year. I’m currently rediscovering my creative side and I also experiment a bit with Photoshop. I have a very keen interest in Japan, its culture and most importantly its technology. I plan to travel to Japan in the future and experience it first-hand. I hope to build a mixed media portfolio that will include videos, codes and other things which may catch my interest.
Thanks for stopping by!