Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <cmath>
- #include <string>
- #include <fstream>
- #include <vector>
- #include <sstream>
- #include <fstream>
- using namespace std;
- string convert2Lower(string phrase) {
- string returnString = "";
- for (int i = 0; i < size(phrase); i++)
- {
- returnString += tolower(phrase[i]);
- }
- return returnString;
- }
- void printSepartaor(int separatorNumber) {
- cout << "-------------This is the end of #"<<separatorNumber <<" of Dailies 4." << endl;
- }
- int main()
- {
- printSepartaor(1);
- int values[10] = { 100234, 23, -5232, 996, 242, 24, 5239, -15, 336, 29 };
- int sum = 0;
- int average = 0;
- int min = 0, max = 0;
- for (size_t i = 0; i < 10; i++)
- {
- sum = sum + values[i];
- if (values[i] > max)
- {
- max = values[i];
- }
- if (values[i] < min)
- {
- min = values[i];
- }
- }
- average = values[10] / 10;
- cout << " The sum is " << sum << ", the max is " << max << ", " << "the min is " << min << ", and the average is " << average << "." << endl;
- printSepartaor(2);
- for (size_t i = 0; i < 9; i++)
- {
- for (size_t j = i + 1; j < 10; j++)
- {
- int temp = 0;
- if (values[i] > values[j])
- {
- temp = values[i];
- values[i] = values[j];
- values[j] = temp;
- }
- }
- }
- cout << "The values in ascending order are: " << endl;
- for (int i = 0; i < 10; i++)
- {
- cout << values[i] << " ";
- }
- cout << endl;
- printSepartaor(3);
- ifstream inputFile;
- inputFile.open("C:\\Users\cis.LABS\Downloads\\rainfall.txt", ios::in);
- if (!inputFile.is_open()) {
- cout << "File could not be opened.\n\n";
- system("pause");
- return 1;
- }
- else {
- cout << "File was opened properly.\n\n";
- }
- ifstream fin("rainfall.txt");
- double number = 0.0, sumtwo = 0.0, averagetwo = 0.0;
- int count = 0;
- double arrayvalues[100000];
- do
- {
- fin >> number;
- sumtwo = sumtwo + number;
- count++;
- } while (number != -999);
- averagetwo = sumtwo / count;
- cout << "The average is " << averagetwo << endl;
- printSepartaor(4);
- string phrasetwo;
- double countVowels;
- double countWords;
- char lettertwo;
- cout << "Enter a phrase. " << endl;
- cin >> phrasetwo;
- int countVowels = 0;
- for (int i = 0; i <phrasetwo.size() ; i++)
- {
- lettertwo = phrasetwo.at(i);
- if (lettertwo == 'a' || lettertwo == 'e' || lettertwo == 'i' || lettertwo == 'o' || lettertwo == 'u' || lettertwo == 'y')
- {
- countVowels++;
- break;
- }
- }
- cout << "The number of vowels are" << countVowels << "and the number of words are " << countWords << "." << endl;
- printSepartaor(5);
- string str1("The brown FOX jumped over the Lazy dog");
- string str2 = convert2Lower(str1);
- istringstream iss(str1);
- while (iss) {
- string word;
- iss >> word;
- int wordSize = size(word);
- char firstLetter = tolower(word[0]);
- switch (firstLetter)
- {
- case 'a':
- case 'e':
- case 'i':
- case 'o':
- case 'u':
- word += "way";
- cout << word << endl;
- break;
- default:
- for (int i = 0; i < wordSize; i++)
- {
- char letter = tolower(word[i]);
- if (letter == 'a' || letter == 'e' || letter == 'i' || letter == 'o' || letter == 'u' || letter == 'y')
- {
- string prefix = word.substr(0, i);
- prefix += "ay";
- word.erase(0, i);
- word += prefix;
- cout << word << endl;
- break;
- }
- }
- break;
- }
- }
- printSepartaor(6);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement