Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
C++ Given string userInput, output "Valid length" if the string's length is less than 6. Otherwise, output "Not short enough". End with a newline.
Ex: If the input is: candles
then the output is: Not short enough
code provided:
#include <string>
using namespace std;
int main() {
string userInput;
getline(cin, userInput);
/* Your code goes here */
return 0;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- // JumpinJava.cpp - This program looks up and prints the names and prices of coffee orders.// Input: Interactive// Output: Name and price of coffee orders or error message if add-in is not found #include <iostream>#include <string>using namespace std; int main(){ // Declare variables. string addIn; // Add-in ordered const int NUM_ITEMS = 5; // Named constant // Initialized array of add-ins string addIns[] = {"Cream", "Cinnamon", "Chocolate", "Amaretto", "Whiskey"}; // Initialized array of add-in prices double addInPrices[] = {.89, .25, .59, 1.50, 1.75}; bool foundIt = false; // Flag variable int x; // Loop control variable double orderTotal = 2.00; // All orders start with a 2.00 charge int findItem(); // Get user input cout << "Enter coffee add-in or XXX to quit: "; cin >> addIn; // Write the rest of the program here. findItem(); foundIt = false x = 0 while(x < NUM_ITEMS) if…arrow_forward// JumpinJava.cpp - This program looks up and prints the names and prices of coffee orders. // Input: Interactive // Output: Name and price of coffee orders or error message if add-in is not found #include <iostream> #include <string> using namespace std; int main() { // Declare variables. string addIn; // Add-in ordered const int NUM_ITEMS = 5; // Named constant // Initialized array of add-ins string addIns[] = {"Cream", "Cinnamon", "Chocolate", "Amaretto", "Whiskey"}; // Initialized array of add-in prices double addInPrices[] = {.89, .25, .59, 1.50, 1.75}; bool foundIt = false; // Flag variable int x; // Loop control variable double orderTotal = 2.00; // All orders start with a 2.00 charge // Get user input cout << "Enter coffee add-in or XXX to quit: "; cin >> addIn; // Write the rest of the program here. return 0; } // End of main()arrow_forwardCode is in C++ Instructions Write a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [] to access a string element. Input is as follows highlighted in bold John Doe 333224444 DoeJ 123Password My problem is with my output, i am close with the code, but i have attached what happens on my output and i cannot figure out why? You can see how it prints out multiple times but i am lost? The terminal image is also attached. Thank you! Here is the code: #include <iostream> //include statement(s)#include <iomanip>#include <string> using namespace std; //using namespace statement(s) void getInfo(string info); //void…arrow_forward
- Alphabe. Using C++ Replace any alphabetic character with '_' in 2-character string passCode. Ex: If passCode is "9a", output is:9_Hint: Use two if statements to check each of the two characters in the string, using isalpha(). #include <iostream>#include <string>#include <cctype>using namespace std; int main() { string passCode; cin >> passCode; if (isalpha(passCode.at(9a))) { passCode = false; } if (isalpha(passCode.at(9_))) { passCode = true; } cout << passCode << endl; return 0;}).arrow_forwardC++ this is my code so far need help with part 9 #include <iostream> #include <string> using namespace std; int GetNumOfNonWSCharacters(const string text); int GetNumOfWords(const string text); int FindText(string text, string sample_text); string ReplaceExclamation(string text); string ShortenSpace(string text); char PrintMenu(){ char option; cout << "\nMENU"<<endl; cout << "c - Number of non-whitespace characters"<<endl; cout << "w - Number of words"<<endl; cout << "f - Find text"<<endl; cout << "r - Replace all !'s"<<endl; cout << "s - Shorten spaces"<<endl; cout << "q - Quit"<<endl; cout<<endl; cout << "Choose an option:"<<endl; cin >> option; return option; } void ExecuteMenu(string sample_text,char option){ if(option == 'c'){ int nonWSCharacters = GetNumOfNonWSCharacters(sample_text); cout << "Number of non-whitespace characters:…arrow_forwardC++arrow_forward
- C++ PLEASE!! // FILE: simplestring.h// CLASS PROVIDED: string (a sequence of characters)//// CONSTRUCTOR for the string class:// string(const char str[ ] = "") -- default argument is the empty string.// Precondition: str is an ordinary null-terminated string.// Postcondition: The string contains the sequence of chars from str.//// CONSTANT MEMBER FUNCTIONS for the string class:// size_t length( ) const// Postcondition: The return value is the number of characters in the// string.//// char operator [ ](size_t position) const// Precondition: position < length( ).// Postcondition: The value returned is the character at the specified// position of the string. A string's positions start from 0 at the start// of the sequence and go up to length( )-1 at the right end.//// MODIFICATION MEMBER FUNCTIONS for the string class:// void operator +=(const string& addend)// Postcondition: addend has been catenated to the end of the string.//// void operator +=(const char addend[ ])//…arrow_forwardAlert dont submit AI generated answer. Please code in C language.arrow_forward3. Word Counter Write a function that accepts a pointer to a C-string as an argument and returns the number of words contained in the string. For instance, if the string argument is "Four score and seven years ago" the function should return the number 6. Demonstrate the function in a program that asks the user to input a string then passes it to the fune- tion. The number of words in the string should be displayed on the screen. Optional Exercise: Write an overloaded version of this function that accepts a string clás object as its argument.arrow_forward
- Code is in C++ Instructions Write a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [] to access a string element. Input is as follows highlighted in bold John Doe 333224444 DoeJ 123Password My problem is with my output, i am close with the code, but i have attached what happens on my output and i cannot figure out why? You can see how it prints out multiple times but i am lost? The terminal image is also attached. Thank you! Here is the code: #include <iostream> //include statement(s)#include <iomanip>#include <string> using namespace std; //using namespace statement(s) void getInfo(string info); //void…arrow_forward// NewMultiply.cpp - This program prints the numbers 0 through 10 along // with these values multiplied by 2 and by 10. // Input: None // Output: Prints the numbers 0 through 10 along with their values multiplied by 2 and by 10. #include <iostream> #include <string> using namespace std; int main() { string head1 = "Number: "; string head2 = "Multiplied by 2: "; string head3 = "Multiplied by 10: "; int numberCounter; // Numbers 0 through 10 int byTen; // Stores the number multiplied by 10 int byTwo; // Stores the number multiplied by 2 const int NUM_LOOPS = 10; // Constant used to control loop // This is the work done in the housekeeping() function cout << "0 through 10 multiplied by 2 and by 10." << endl; // This is the work done in the detailLoop() function // Write your for loop here. // This is the work done in the endOfJob() function return 0; } // End of main()arrow_forwardc++ progamming Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is "quit". If the input is:arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education