I need someone to help me with this homework problem.
I need to write a program that tells the user to enter a string that includes a combination of letters
(uppercase or lower), digits, spaces, punctuation marks and/or any other keyboard symbols.
Thank you if you help me and I would appreciate it.
I don't get what you're trying to do. You want the computer to ask the user for a string input (allowing the user to enter every character?)
If that's the case, here you are:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include "stdafx.h"
#include <iostream>
#include <string>
int main()
{
std::cout << "Please enter something: \n";
std::string string; // to get a string
getline(std::cin, string); // getline to read every character (input)
std::cout << "You entered: " << string << std::endl;
return 0;
}
Thank you very much for responding, but here is what I need to do:
// Return the true if a character is one of the following punctuation marks: ,.?;:”’{}[] /
bool isPunctuationMark(char c)
// Return the true if a character is a vowel (a, e, i, o, or u) or (A, E, I, O, or U)
bool isVowel(char c)
// Return the reversed string of a string
string reverseString(string i)
Here is the following code:
#include <iostream>
#include <string>
using namespace std;
bool isVowel(char c)
{
}
bool isPunctuationMark(char c)
{
}
int main()
{
// program need to read in a string (including spaces);
OK so that looks like the template your were given. So what have you added to it, for example what have you written for reading in a string with spaces? Hint: check getline function
Well, I think you need to take the advice you have already been given - twice now. Break the problem down into steps and do the first step of reading in the string and printing it out.
If you can't do that then I'd suggest you read your notes and textbook and don't even consider going onto the reverse string part, especially because there are other parts preceding it. Maybe you should have a talk with your teacher/tutor too and get some guidance.
Given your questions on other problems here you have posted you also need to be clear that this is not a homework site. If you make some effort to attempt the problem solutions yourself then you'll find that plenty of help is available. The reverse is not so productive for you. :)
bool isVowel(char c)
{
switch(c)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
return true; break;
default:
return false;
}
}
bool isPunctuationMark(char c)
{
const string punct = "+=%₩<>!@#~/^&*()-\'\":;,\?`_\\|{}[]$€£¥";
return punct.find(c);
}
int main()
{
//char str[100];
string line;
int vowels, consonants, digits, spaces, upper, lower;