
Read a 3-character string from input into variable inputString. Declare a Boolean variable isValid and assign isValid with true if inputString only contains alphabetic characters. Otherwise, assign isValid with false.
Ex: If the input is hgr, then isValid is assigned with true, so the output is:
Valid string
Ex: If the input is 3rx, then isValid is assigned with false, so the output is:
Invalid string
Note: Use getline(cin, inputString) to read the entire line from input into inputString.
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
string inputString;
/* Your code goes here */
if (isValid) {
cout << "Valid string" << endl;
}
else {
cout << "Invalid string" << endl;
}
return 0;
}

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps

- Orinoco rewards loyal customers with discounts as shown in the table below. Write a program that prompts shoppers for the price of a purchase and their accumulated loyalty points. Then, use f-strings to report the amount of the discount, the reduced price before sales tax, the sales tax at 7%, and the total cost of the purchase. LOYALTY POINTS DISCOUNT 100 or more 25% 80 to 99 20% 60 to 79 15% 40 to 59 10% 0 to 39 None written in pythonarrow_forwardYou are given a string ternary_expr which represents a random nested ternary expression, you need to evaluate this expression, and report the result. Assumption can be as follows: ● ternary_expr only contains digits, ‘?’, ‘:’, ’T’, ‘F’ where ’T’ is true and ‘F’ is false. ● ternary_expr contains only one-digit numbers (i.e. in the range [0, 9]) The ternary expressions group right-to-left, and the result of the expression will always evaluate to either a digit, 'T' or 'F'. Requirements 1. Way of modeling the problem with the cost implications without using Stacks.arrow_forwardGiven string inputString on one line and integers idx1 and idx2 on a second line, output "Match found" if the character at index idx1 of inputString is equal to the character at index idx2. Otherwise, output "Match not found". End with a newline. Ex: If the input is: banana 1 3 then the output is: Match found Note: Assume the length of string inputString is greater than or equal to both idx1 and idx2. import java.util.Scanner; public class CharMatch { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String inputString; int idx1; int idx2; inputString = scnr.nextLine(); idx1 = scnr.nextInt(); idx2 = scnr.nextInt(); /* Your code goes here */ }}arrow_forward
- C++arrow_forwardScilab answer only, no MatLab. Will give thumbs down for MatLab answer! immediate thumbs up for scilab solution.arrow_forward7. Let the statements A, B be given by A: not(p or q), B: (not p) or q. Let T = true, F = false. If p = T and q = F, then O A = T, B = T O A = F, B = T O A = F, B = F O A= T, B = Farrow_forward
- Read a 2-character string from input into variable userString. Declare a Boolean variable isValid and assign isValid with true if userString does not contain any uppercase letters. Otherwise, assign isValid with false. Ex: If the input is 86, then isValid is assigned with true, so the output is: Good string Ex: If the input is BQ, then isValid is assigned with false, so the output is: Bad string Note: Use getline(cin, userString) to read the entire line from input into userString. #include <iostream>#include <string>#include <cctype>using namespace std; int main() { string userString; /* Your code goes here */ if (isValid) { cout << "Good string" << endl; } else { cout << "Bad string" << endl; } return 0;}arrow_forwardIn C++ Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not exactly 1. Ex: If the input is: n Monday the output is: 1 n Ex: If the input is: z Today is Monday the output is: 0 z's Ex: If the input is: n It's a sunny day the output is: 2 n's Case matters. n is different than N. Ex: If the input is: n Nobody the output is: 0 n's The program must define and call the following function that takes the input string and character as parameters, and returns the number of times the input character appears in the input string.int CalcNumCharacters(string userString, char userChar)arrow_forwardC++ Read in a 2-character string from input into variable userCode. Declare a boolean variable containsLowercase and set containsLowercase to true if userCode contains a lowercase letter. Otherwise, set containsLowercase to false. Note: the tests will b Ex: If the input is z$, then containsLowercase is assigned with true, so the output is: Valid passcode Ex: If the input is CY, then containsLowercase is assigned with false, so the output is: Invalid passcode Note: Use getline(cin, userCode) to read the entire line from input into userCode.arrow_forward
- 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





