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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
#include<iostream>
#include<string>
#include<assert.h>
using namespace std;
void welcome();
void getBabyName(string &babyName);
int findVowel(char, string);
void findHighest(int, int, int, int, int);
int main()
{
string babyName;
int vowelA, vowelE, vowelI, vowelO, vowelU;
int first = 0;
string firstString = "";
int second = 0;
string secondString = "";
cout << welcome;
cout << getBabyName;
vowelA = findVowel('a', babyName);
vowelE = findVowel('e', babyName);
vowelI = findVowel('i', babyName);
vowelO = findVowel('o', babyName);
vowelU = findVowel('u', babyName);
if (firstString != secondString)
{
cout << babyName.substr(0, babyName.find(' ')) << firstString << "," << secondString << ".";
}
else
{
cout << babyName.substr(0, babyName.find(' ')) << firstString << ".";
}
}
void welcome()
{
cout << "******************************************************************" << endl;
cout << " BABY SAYINGS PROGRAM " << endl;
cout << " Please Enter Your Baby’s Full Name " << endl;
cout << " Program Developed by: Austin Schlusemeyer " << endl;
cout << "******************************************************************" << endl;
}
void getBabyName(string &babyName)
{
cout << "Please enter the Baby's name: ";
getline(cin, babyName);
do
{
cout << "Try again";
getline(cin, babyName);
} while (babyName.empty() == true);
}
int findVowel(char x, string babyName)
{
int counter = 0;
int counterX = 0;
do
{
if (babyName.at(counter) == x)
counterX++, counter++;
else
counter++;
} while (counter < babyName.length());
return counterX;
}
void findHighest(int vowelA, int vowelE, int vowelI, int vowelO, int vowelU)
{
int first = 0;
string firstString = "";
int second = 0;
string secondString = "";
if (vowelA > first)
{
first = second;
vowelA = first;
firstString = "a little bit of heaven sent down to earth";
secondString = "this is the start of your own sweet story";
}
else
if (vowelA > second)
{
vowelA = second;
firstString = "this is the start of your own sweet story";
secondString = "a little bit of heaven sent down to earth";
}
else
{
firstString = "this is the start of your own sweet story";
secondString = "this is the start of your own sweet story";
}
if (vowelE > first)
{
first = second;
vowelE = first;
firstString = "everything is beautiful because we have you now";
}
else
if (vowelE > second)
{
vowelE = second;
secondString = "everything is beautiful because we have you now";
}
if (vowelI > first)
{
first = second;
vowelI = first;
firstString = "in everything you do, dream big";
}
else
if (vowelI > second)
{
vowelI = second;
secondString = "in everything you do, dream big";
}
if (vowelO > first)
{
first = second;
vowelO = first;
firstString = "oh, don't you know you will be my greatest adventure";
}
else
if (vowelO > second)
{
vowelO = second;
secondString = "oh, don't you know you will be my greatest adventure";
}
if (vowelU > first)
{
first = second;
vowelU = first;
firstString = "u are my happy";
}
else
if (vowelU > second)
{
vowelU = second;
secondString = "u are my happy";
}
}
|