Question
please help!! some of the testcases are failing and i dont know why. Here is the question: Write a program in C++.Prompt the user for
please help!! some of the testcases are failing and i dont know why.
Here is the question:
Write a program in C++.Prompt the user for his/her first name. Output the user's nickname. Use this algorithm to generate a nickname:
If the first letter in the user's name is odd according to the ASCII chart, output "Big" followed by the first three letters of the name.
If the first letter in the user's name is even according to the ASCII chart, output "Lil" followed by the first four letters of the name.
Here is my code:
#include
//Returns false otherwise
bool verify(string name)
{
//assume that all characters in the string are letters
bool valid_string = true;
for(int subscript = 0; subscript < name.length(); subscript++)
{
if (isdigit(name[subscript]))//if (the current character is a digit)
valid_string = false;//this string is no longer valid
else if(ispunct(name[subscript]))//if (the current character is a punct)
valid_string = false;//this string is no longer valid
}
//go back to where we left off -- bring the result
return valid_string; } int main() { string name; cout << "Enter your first name" << endl; cin >> name; if (verify(name)) { cout << "Your nickname is:" < Required output: (The wrong outputs that are mine are marked with 3 stars) Required Output Your Program's Output Test Case 2 - Failed Required Output Your Program's Output *** Test Case 3 - Passed! Required Output Your Program's Output Test Case 4 - Failed Required Output Your Program's Output *** Test Case 5 - Passed! Required Output Your Program's Output Test Case 6 - Passed! Required Output Your Program's Output Test Case 7 - Passed! Required Output Your Program's Output Test Case 8 - Failed Required Output Your Program's Output *** Test Case 9 - Failed Required Output Your Program's Output *** Test Case 10 - Passed! Required Output Your Program's Output Test Case 11 - Passed! Required Output Your Program's Output
Standard Input Andrew
Enter your first name Your nickname is: Big And
Enter your first name Your nickname is: Big And
Standard Input Barney
Enter your first name Your nickname is: Lil Barn
Enter your first name Your nickname is: Big Bar (Your output is too short.)
Standard Input Cammy
Enter your first name Your nickname is: Big Cam
Enter your first name Your nickname is: Big Cam
Standard Input Daniel
Enter your first name Your nickname is: Lil Dani
Enter your first name Your nickname is: Big Dan (Your output is too short.)
Standard Input Eddie
Enter your first name Your nickname is: Big Edd
Enter your first name Your nickname is: Big Edd
Standard Input Michael
Enter your first name Your nickname is: Big Mic
Enter your first name Your nickname is: Big Mic
Standard Input Stuart
Enter your first name Your nickname is: Big Stu
Enter your first name Your nickname is: Big Stu
Standard Input Xerxes
Enter your first name Your nickname is: Lil Xerx
Enter your first name Your nickname is: Big Xer (Your output is too short.)
Standard Input Yasmine
Enter your first name Your nickname is: Big Yas
Enter your first name Your nickname is: Lil Yasm
Standard Input Zenith
Enter your first name Your nickname is: Lil Zeni
Enter your first name Your nickname is: Lil Zeni
Standard Input And+rew
Enter your first name Only letters are allowed.
Enter your first name Only letters are allowed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started