Question

In: Computer Science

I need this assignment in RAPTOR please. Many websites ask for phone numbers. The problem is...

I need this assignment in RAPTOR please. Many websites ask for phone numbers. The problem is that there are many different ways to represent a phone number. Examples include 817-555-1234, 817 555 1234 (c), and (817) 555-1234 x23. Write a Raptor program which inputs a string containing a phone number in any format and outputs it in the standard format. For this assignment, the standard format is (817) 555-1234. Your Raptor program should: 1. Input a string including the number 2. Copy only the digits from the input string into another string 3. Issue an error message if the input string does not contain at least 10 digits 4. If the input string contains more than 10 digits, include only the first 10 digits in the formatted number 5. Output the phone number in standard format Notes: 1. In Raptor, a string is just an array of characters. 2. Lesson #9 has an example of working with strings in Raptor. 3. When only digits are input, Raptor assumes it is an integer instead of a string. Your flowchart does not need to properly handle an input like 8175551234, but your C++ version does need to handle that. 4. I recommend passing the digits only string to a procedure which outputs it in the standard format. Sample Output (inputs in bold) Please enter a phone number: 817-555-1234 The properly formatted number is (817) 555-1234 Please enter a phone number: (817)515 7259 x23 The properly formatted number is (817) 515-7259 Please enter a phone number: 214-555-999 The phone number must have at least 10 digits Please enter a phone number: 800**4444xxx333 The properly formatted number is (800) 444-4333

Solutions

Expert Solution

Screenshot

Remaining

Program

#include <iostream>
#include <string>

using namespace std;
int main()
{
   string raptor_prompt_variable_zzyz;
   ?? val;
   ?? i;
   ?? phonenum;
   ?? phone_number;
   ?? phone;

   raptor_prompt_variable_zzyz ="Ente rstring of phone number: ";
   cout << raptor_prompt_variable_zzyz << endl;
   cin >> phonenum;
   if (phonenum'Length<10)
   {
      cout << "ERROR!!!!Length of phone number should be 10" << endl;   }
   else
   {
      i =1;
      phone ="";
      while (!(i>phonenum'Length))
      {
         val =phonenum(i);
         if (((int) val)>=48 && ((int) val)<=57)
         {
            phone =phone+val;
         }
         else
         {
         }
         i =i+1;
      }
      if (phone'Length<10)
      {
         cout << "ERROR!!!!Length of phone number digits should be 10" << endl;      }
      else
      {
         i =1;
         phone_number ="(";
         while (!(i>10))
         {
            if (i==4)
            {
               phone_number =phone_number+") "+phone(i);
            }
            else
            {
               if (i==7)
               {
                  phone_number =phone_number+"-"+phone(i);
               }
               else
               {
                  phone_number =phone_number+phone(i);
               }
            }
            i =i+1;
         }
         cout << "Phone Number = "+phone_number << endl;      }
   }

   return 0;
}

-----------------------------------------------------------

Output

Phone Number = (817) 555-1234
----Run complete. 143 symbols evaluated.----
Phone Number = (817) 515-7259
----Run complete. 170 symbols evaluated.----
----Reset----
ERROR!!!!Length of phone number digits should be 10
----Reset----
Phone Number = (800) 444-4333


Related Solutions

I also need the references in this assignment. What's in bold are the websites that can...
I also need the references in this assignment. What's in bold are the websites that can be used. Throughout the course, you have been learning about managed care, both past and present. Conduct additional research on trends happening in managed care today. The following websites are a great place to start: Centers for Medicare & Medicaid Services Kaiser Family Foundation (Search for the series on health care marketplace trends.) You can also visit the following videos related to managed care...
I need to ask a user what numbers they want to enter. They can enter as...
I need to ask a user what numbers they want to enter. They can enter as many as they like. Then inside I need to use conditionals to determine if the numbers are <=20, <=323 && > 30, >200. I can't figure out how to let the user enter as many inputs as they want. I know I need to use a loop to check each number entered and determine if it is small middle or greater but I can't...
Please I need answer for This question I have assignment for this subjects . Please be...
Please I need answer for This question I have assignment for this subjects . Please be brief and to the point . Write than 3 pages (maximum),but It is enough to give the name of the authors Only legible answers will be considered.Thanks in advance/Ha !-What are Structural discrimination in the housing market in Sweden?.Give an overview of the theories of discrimination used in economics. What are the main differences between these theories?
Please I need answer for This question I have assignment for this subjects . Please be...
Please I need answer for This question I have assignment for this subjects . Please be brief and to the point . Write than 3 pages (maximum),but It is enough to give the name of the authors Only legible answers will be considered.Thanks in advance/Ha 1-Discrimination in the Swedish housing market ?Give an overview of the theories of discrimination used in economics. What are the main differences between these theories?
Please I need answer for This question I have assignment for this subjects . Please be...
Please I need answer for This question I have assignment for this subjects . Please be brief and to the point . ,but It is enough to give the name of the authors Only legible answers will be considered.Thanks in advance/Ha 1- Give an overview of the Becker theory of Discrimination. a-Discrimination definition. b-Explicit Discrimination . c-Hypothesis formulation.
This is the assignment I have, I need the best game theory problem example for it...
This is the assignment I have, I need the best game theory problem example for it which is difficult. Thank you:) Think of an example of a decision problem or a game theory problem. This time you will have to submit the source of the story. You can take it from a newspaper, from Internet, magazine, book... 1. Submit a photocopy or a printed version of your problem. 2. Simplify the problem and represent it using the concepts of game...
I have to submit a question and a solution to a problem for an assignment. Please...
I have to submit a question and a solution to a problem for an assignment. Please help! Select a single concept or topic covered in this course (e.g. regression, t-testing, ANOVA, correlation, etc) and create a supplemental material explaining it and its use. Aspects of your explanation may include: - When to use this statistical test. - How this statistical test functions - How this statistical test is computed - What are the assumptions of this statistical test? - Worked...
IN JAVA PLEASE ASAP !!! I just need the main and mergesort function Ask the user...
IN JAVA PLEASE ASAP !!! I just need the main and mergesort function Ask the user for the number of elements, not to exceed arraySize = 20 (put appropriate input validation) Ask the user for the type of data they will enter - EnglishGrade or MathGrade objects. Use your EnglishGrade and MathGrade classes Based on the input, create an appropriate array for the data to be entered. Write a helper function called recursionMergeSort such that: It is a standalone function...
i REALLY NEED REPLY AS SOON AS POSSIBLE: PLEASE PLEASE MAKE THE ASSIGNMENT ON THIS TASK...
i REALLY NEED REPLY AS SOON AS POSSIBLE: PLEASE PLEASE MAKE THE ASSIGNMENT ON THIS TASK OF Business Ideas based on a indian restaurants Purpose: Develop and formulate an idea for your own business. Money is not an issue for this assignment. Envision that you get all the funding you need to start it up. Task: Write a short abstract (200-250 Words) describing your business idea in the discussion section of this assignment. What is the basic idea? What are...
i REALLY NEED REPLY AS SOON AS POSSIBLE: PLEASE PLEASE MAKE THE ASSIGNMENT ON THIS TASK...
i REALLY NEED REPLY AS SOON AS POSSIBLE: PLEASE PLEASE MAKE THE ASSIGNMENT ON THIS TASK OF Business Ideas based on a indian restaurants Purpose: THIS IS THE QUESTION : Develop and formulate an idea for your own business. Money is not an issue for this assignment. Envision that you get all the funding you need to start it up. Task: Write a short abstract (200-250 Words) describing your business idea in the discussion section of this assignment. What is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT