Question

In C++ write validation function A company requires  that a valid customer numbers must be in the...

In C++ write validation function

A company requires  that a valid customer numbers must be in the format of LLLNNNN ( three upper case letters followed by four digits). Please write a function called isValid that takes a string as an argument and returns  if the string is a valid customer number.

Homework Answers

Answer #1

source code:

*******************************************************************************/
#include <cctype>
#include <iostream>
#include <cstring>

using namespace std;
bool isValid(string str);
int main()
{
string str;
cout<<"Enter Customer number : ";
cin>>str;
  
if(isValid(str))
{
cout<<"Customer number is valid";
return 0;
}

cout<<"Customer number is invalid";
return 0;
}

bool isValid(string str)
{
if(str.length()==7)
{
if(isupper(str[0]) &&isupper(str[1])&&isupper(str[2])&&isdigit(str[3])&&
isdigit(str[4])&&isdigit(str[5])&&isdigit(str[6]))
return true;
else{
return false;
}
}
else{
return false;
}
}

if you have nay doubts ask me..

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using nested loops, write a function called primes(a,b) that takes in two positive integers a and...
Using nested loops, write a function called primes(a,b) that takes in two positive integers a and b (where a<b). Then simply RETURNS a string containing all the prime numbers between a and b (or if there are none, the string "No Primes"). You should check that a and b are valid inputs, that is, that a and b are integers such that a<b (otherwise, the function should print “No Primes”). Three sample calls of your function (in IDLE) should produce...
1. Write 3n + 1 Sequence String Generator function (1 point) In lab5.py complete the function...
1. Write 3n + 1 Sequence String Generator function (1 point) In lab5.py complete the function sequence that takes one parameter: n, which is the initial value of a sequence of integers. The 3n + 1 sequence starts with an integer, n in this case, wherein each successive integer of the sequence is calculated based on these rules: 1. If the current value of n is odd, then the next number in the sequence is three times the current number...
1. Please write the following in C++ also please show all output code and comment on...
1. Please write the following in C++ also please show all output code and comment on code. 2. Also, use CPPUnitLite to write all test and show outputs for each test. Write CppUnitLite tests to verify correct behavior for all the exercises. The modifications are aimed at making the exercises more conducive to unit tests. Write a function that swaps (exchanges the values of two integers). Use int* as the argument type. Write a second swap function using a reference...
solve in python 3.8 please The question is about Strings Modify your function so that it...
solve in python 3.8 please The question is about Strings Modify your function so that it can handle the following two situations: The string given as an argument has no characters. In this case, you should return the empty string. The string given as an argument has one character. In this case, you should return the one-character string given to you. Without any consideration for these cases, your function probably causes an error or returns the wrong result in the...
Write a function called char_counter that counts the number of a certain character in a text...
Write a function called char_counter that counts the number of a certain character in a text file. The function takes two input arguments, fname, a char vector of the filename and character, the char it counts in the file. The function returns charnum, the number of characters found. If the file is not found or character is not a valid char, the function return -1. As an example, consider the following run. The file "simple.txt" contains a single line: "This...
For C++: a) Write a function is_prime that takes a positive integer X and returns 1...
For C++: a) Write a function is_prime that takes a positive integer X and returns 1 if X is a prime number, or 1 if X is not a prime number. b) write a program that takes a positive integer N and prints all prime numbers from 2 to N by calling your function is_prime from part a.
Write the following in C: 2. An integer is said to be prime if it is...
Write the following in C: 2. An integer is said to be prime if it is divisible by only 1 and itself. Write a function called prime() that takes in one integer number, and returns 1 (true) if the number is prime and 0 (false) otherwise. Write a program to generate six random numbers between 1 to 100 and calls function prime() on each one to determine if it is prime or not.
Write a function in (C++) named - accending_order - that takes a reference to a vector...
Write a function in (C++) named - accending_order - that takes a reference to a vector of string (like {"HI 32", "HELLO 78", "NAME 97", "WORLD 07"}), and returns nothing. The function should reorder the vector so that the courses are sorted by number in ascending order. Write this function without - int (main). CODE IN C++ ONLY. EXPECTED OUTPUT: {"WORLD 07", "HI 32", "HELLO 78", "NAME 97"}
Write a function num_day that takes a number in the range of 1 through 7 as...
Write a function num_day that takes a number in the range of 1 through 7 as a parameter and returns a string representing the corresponding day of the week, where 1=Monday, 2 =Tuesday, 3= Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, and 7 = Sunday. The function should return the string "Error" if the parameter is that is outside the range of 1 through 7. You may assume that the parameter will be only numbers. Save the...
Using C programming Create a function called printMenu( ) with the following properties: Has no function...
Using C programming Create a function called printMenu( ) with the following properties: Has no function inputs or output. Prints the following menu to the screen: 1. Enter user name. 2. Enter scores. 3. Display average score. 4. Display summary. 5. Quit Create a function called printLine( ) with the following properties: Takes as input a char Takes as input an integer corresponding to the number of times to print the character Has no function output. For example, if we...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • Plato states in the Phaedo that: “either knowledge is nowhere to be gained, or else it...
    asked 5 minutes ago
  • 1. The nucleus is a membrane-bound organelle that contains the cells genetic information. What other intracellular...
    asked 20 minutes ago
  • Do genetics play a significant role in human attraction? Defend a position (yes or no). Use...
    asked 42 minutes ago
  • 9.14 The quality-control manager at a compact flu-orescent light bulb (CFL) factory needs to determine whether...
    asked 47 minutes ago
  • Describe a business you are familiar with. Discuss ONE way this firm adjusts its short-term capacity...
    asked 1 hour ago
  • Write a persuasive speech on whether online or face to face learning/education is better for students
    asked 1 hour ago
  • (a) As an analyst briefly explain what you will consider in applying nested designs (b) State...
    asked 1 hour ago
  • Metals are good thermal conductors — that is, when there is a temperature difference across their...
    asked 1 hour ago
  • Theoretical Perspectives that attempts to explain and answer fundamental questions why societies form and why they...
    asked 1 hour ago
  • I am working with data analysis and with a survey. I am cleaning up the following...
    asked 1 hour ago
  • For this problem, carry at least four digits after the decimal in your calculations. Answers may...
    asked 1 hour ago
  • The International Air Transport Association surveys business travelers to develop quality ratings for transatlantic gateway airports....
    asked 1 hour ago