Preview

Char D1

Good Essays
Open Document
Open Document
599 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Char D1
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int ReadDials (char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8); int ToDigit (char &digit); void AcknowledgeCall (char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8);

int main ()
{
// Char variables for the 8 digits of the phone number. char d1, d2, d3, d4, d5, d6, d7, d8;

while (1) { int errorCode = ReadDials(d1, d2, d3, d4, d5, d6, d7, d8);

if (errorCode == -5) break; // Exit the while loop.

switch(errorCode) { case -1: cout << "ERROR - An invalid character was entered" << endl << endl; break;

case -2: cout << "ERROR - Phone number cannot begin with 0" << endl << endl; break;

case -3: cout << "ERROR - Phone number cannot begin with 555" << endl << endl; break;

case -4: cout << "ERROR - Hyphen is not in the correct position" << endl << endl; break;

default: AcknowledgeCall(d1, d2, d3, d4, d5, d6, d7, d8); break; } }

char ch, line[80]; cin.getline(line, 80);

cout << "Press any key to continue..."; cin.get(ch);

return 0;
}

int ReadDials (char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8)
{
cout << "Enter a phone number (Q to quit): "; cin >> d1; // Input the first digit.

if (d1 == 'Q') return -5; // User wants to quit.

// Input the rest of the phone number. cin >>

You May Also Find These Documents Helpful

  • Satisfactory Essays

    NT1210 Lab 1

    • 319 Words
    • 4 Pages

    3. First 4 digits of a Base 5 numbering system would be (left to right) 625 125 25 5…

    • 319 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    a1 script win213

    • 380 Words
    • 2 Pages

    If the user does not enter a numeric value the program should prompt for a numeric value…

    • 380 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    CGS 2531 Notes Ch. 1-5

    • 2861 Words
    • 11 Pages

    You can also use this for sequences such as January and quartesFor values input first 2 #’s…

    • 2861 Words
    • 11 Pages
    Good Essays
  • Satisfactory Essays

    cout << "You are in factorial program of C++. Please enter a +ve integer:- ";…

    • 426 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    System.out.println("i = " + i + " f = " + f + " d = " + d);…

    • 2338 Words
    • 10 Pages
    Powerful Essays
  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    9.Write a program to count the number of characters in an input line. Page: 105…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Nt1310 Unit 3 Assignment

    • 256 Words
    • 2 Pages

    Write a program to input a string and then display it in Upper Case and also print the frequency of any character from the string.…

    • 256 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Array Structure Paper

    • 833 Words
    • 4 Pages

    Once again Berry’s Bug Blasters are requesting an update to the previous program that was designed to help them to better serve their customers. The company has requested a way to display the name and phone number of their clients so that they can keep a record of what clients have called. The best way in the opinion to accomplish this is to build an array into the program. This will allow those in charge of the company record to record who has called and then to display the names of the clients and their number in a chart so that it can be recalled at a later date as needed.…

    • 833 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Telephone systems have many different features this allows us to handle and manage calls in a professional manner.…

    • 3590 Words
    • 17 Pages
    Powerful Essays
  • Satisfactory Essays

    Comp122 Week 2 Homework

    • 301 Words
    • 2 Pages

    What values (if any) are stored in x, y, z, and ch if the input is:…

    • 301 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Chapter 8 Quiz

    • 469 Words
    • 2 Pages

    3. Access the individual elements in an array by using their _____________. (Points : 6)…

    • 469 Words
    • 2 Pages
    Good Essays
  • Good Essays

    U2 Assessment

    • 3300 Words
    • 12 Pages

    The keypad has pre-set dial numbers, each button or key sends call to a specific number. They are used to make regular calls easier with one touch only.…

    • 3300 Words
    • 12 Pages
    Good Essays
  • Satisfactory Essays

    Lab 3 Student

    • 1264 Words
    • 7 Pages

    Step 3: Write the exact output you would expect from the following line of code if the user of the program enters “Nolan Owens”. (Reference: Displaying Items, page 40 – 41).…

    • 1264 Words
    • 7 Pages
    Satisfactory Essays
  • Good Essays

    Business Admin

    • 2545 Words
    • 11 Pages

    A telephone system has many different features that help us to handle and manage calls in a polite manner.…

    • 2545 Words
    • 11 Pages
    Good Essays
  • Good Essays

    Java

    • 490 Words
    • 3 Pages

    Each phone number begins with the digit 2 or greater so phone numbers are 2000000 through 9999999. There are no area codes or country code prefixes to deal with. The file looks something like:…

    • 490 Words
    • 3 Pages
    Good Essays