67 172
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #17258 in C++ for Mikey

Question #17258
Student e-mail IDs at pace University consist of the first and last initials of the student, followed by five digits, followed by either the letter n or the letter p. write a program that asks the user to enter a Pace e-mail ID. The program should then validate the form of the ID as just described. If the ID is invalid, the program should tell the user which part (or parts) of the ID is invalid. If the ID is valid, the program should display an appropriate message.
Expert's answer
#include<iostream>

#include<conio.h>

using namespace std;

int main()

{

char string[128];

cin.getline(string, sizeof(string));




if (!isalpha(string[0])) {

cout << "1 character is NOT a letter" << endl;

}

if(!isalpha(string[1])) {

cout << "2 character is NOT a letter" << endl;

}

if(!isdigit(string[2])) {

cout << "3 character is NOT a digit" << endl;

}

if(!isdigit(string[3])) {

cout << "4 character is NOT a digit" << endl;

}

if(!isdigit(string[4])) {

cout << "5 character is NOT a digit" << endl;

}

if(!isdigit(string[5])) {

cout << "6 character is NOT a digit" << endl;

}

if(!isdigit(string[6])) {

cout << "7 character is NOT a digit" << endl;

}

if(!isalpha(string[7])) {

cout << "8 character is NOT a letter" << endl;

}

cout << endl;

getch();

return 0;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions