Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8927593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:15:09+00:00 2026-06-15T08:15:09+00:00

I have written the entire program myself, the program is suppose to simulate incoming

  • 0

I have written the entire program myself, the program is suppose to simulate incoming calls on a cellphone. I have fixed every error on the program but I have never been able to successfully pull in the numbers line by line into the queues I have made. My question is what is the proper way for me to draw in the lines from the text using getline? Here is my program.

#include <string>
#include <queue>
#include <deque>
#include <iostream>
#include <fstream>
#include <stack>
using namespace std;

class cell
{
    public:
        cell();
        void upload( string left );//Insert in order.
        void printnew();//Print call just recieved.
        void printlater();//Print calls for later.
        void decidenew();// Prompts user to decide what to do with recent calls.
        void decidelater();// Prompts user to decide what to do with call back numbers.
        void correctionnew();//Corrects the amount of numbers in new calls list.
        void correctionlater();//Correxts the amount of number in the call back list.

    private:
        queue<string> N;
        queue<string> O;
        queue<string> T;
        stack<string> Tem;

};

int main()
{
    string left;
    int i=1;
    cell num;
    num.upload( left );
    int n=1;

    while(i != 3)
    {
            cout << "Please check for recent calls." << endl;
            num.upload(left);
            cout << "This is the main menu and here are your options:" << endl;
            cout << "Press 1 to view your recent calls" << endl;
            cout << "Press 2 to view your call back list" << endl;
            cout << "Press 3 to turn off cellphone" << endl;

            cin >> i;
            if(i = 1)
            {
                 num.printnew();
                 num.decidenew();
                 num.correctionnew();
                 num.correctionlater();
            }
            if(i = 2)
            {
                 num.printlater();
                 num.decidelater();
            }
    }


    system("Pause");
    return 0;
}

void cell::printnew()
{
     cout << "Here is the list of the latest callers:" << endl;
     while(N.empty())
     {
          cout << N.front();
          T.push(N.front());
          N.pop();
     }

     while(T.empty())
     {
          N.push(T.front());
          T.pop();
     }
}

void cell::printlater()
{
     cout << "Here is the list of your call back list:" << endl;
     while(!O.empty())
     {
          cout << O.front();
          T.push(O.front());
          O.pop();
     }

     while(!T.empty())
     {
          O.push(T.front());
          T.pop();
     }
}
void cell::decidenew()
{
     int p=0;
     while(!N.empty() || p != 4)
     {
         cout << "What would you like to do with" << N.front() << "?" << endl;
         cout << "You can:" << endl;
         cout << "Press 1 to call back." << endl;
         cout << "Press 2 to ignore the call." << endl;
         cout << "Press 3 to Send to call back list." << endl;
         cout << "Press 4 to return to the main menu." << endl;
         cin >> p;

         if(p = 1)
         {
             N.pop();
         }
         else if(p = 2)
         {
             N.pop();
         }
         else if(p = 3)
         {
             O.push(N.front());
             N.pop();
             while(!O.empty() || N.front() != O.front())
             {
                 T.push(O.front());
                 O.pop();
             }
             if (N.front() != O.front())
             {
                 O.push(N.front());
                 N.pop();
             }
             while(!O.empty())
             {
                 T.push(O.front());
                 O.pop();
             }
             while(!T.empty())
             {
                 O.push(T.front());
                 T.front();
             }              
         }
         else if(p = 4)
         {
         }
         else
         {
             cout << "That is an incorrect input, please try again." << endl;
         }

     }
}
void cell::decidelater()
{
     int dummy = 0;
     while(!O.empty() || dummy != 4 )
     {
         cout << "What would you like to do with" << O.front() << "?" << endl;
         cout << "You can:" << endl;
         cout << "Press 1 to call back." << endl;
         cout << "Press 2 to delete number." << endl;
         cout << "Press 3 to keep and call later." << endl;
         cout << "Press 4 to go back to main menu." << endl;
         cin >> dummy;

         if( dummy = 1)
         {
             O.pop();
         }
         else if( dummy = 2)
         {
              O.pop();
         }
         else if( dummy = 3)
         {
              T.push(O.front());
              O.pop();
         }
         else if( dummy = 4)
         {
         }
         else
         {

             cout << "That is an incorrect input, please try again." << endl;
         }
         while(!T.empty())
         {
             O.push(T.front());
             T.pop();
         }
     }
}
void cell::upload( string left)
{
    int g = 0;
    string item;
    fstream myfile;
    myfile.open("CALLS.txt");
    while(!myfile.eof || g != 3)
    {
        getline( myfile, left);
        while(!N.empty() || left != N.front())
        {
            T.push(N.front());
            N.pop();
        }
        if(left != N.front())
        {
        N.push(left);
        }
        while(!N.empty())
        {
            T.push(N.front());
            N.pop();
        }
        while(!T.empty())
        {
           N.push(T.front());
           T.pop();
        }

        g++;
    }
    while(!N.empty())
    {
        Tem.push(N.front());
        N.pop();
    }
    while(!Tem.empty())
    {
        N.push(Tem.top());
        Tem.pop();
    }
    g=0;
}
void cell::correctionnew()
{
     int l = 0;
     while(!N.empty())
     {
         T.push(N.front());
         N.pop();
     }
     while(!T.empty() || l != 8)
     {
         N.push(T.front());
         T.pop();
         l++;
     }
}
void cell::correctionlater()
{
     int m = 0;
     while(!O.empty())
     {
         T.push(O.front());
         O.pop();
     }
     while(!T.empty() || m != 3)
     {
         O.push(T.front());
         T.pop();
         m++;
     }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:15:10+00:00Added an answer on June 15, 2026 at 8:15 am

    I don’t think this code is supposed to compile. If it does compile, the problem is clearly what shouldn’t compile:

    while (!myfile.eof || g != 3)
    

    This line has two problems, one of them preventing it from compiling (you probably meant to write myfile.eof(); note the extra parenthesis), the other being semantics (assuming the missing parenthesis are added): The stream cannot know ahead of time what is attempted to be read. Thus, it is always necessary to check after the attempt to read if the read was successful. This line should probably look like this instead:

    while (g != 3 && std::getline(myfile, left))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written an entire app pretty successfully in Django but I have this nagging
have written this little class, which generates a UUID every time an object of
I have written a java program generates lots of files (say txt files) in
This is what I am trying to do: I have written a Java program
I have written a multithreaded program which does some thinking and prints out some
I am an intermediate level Python Programmer and I have written a Python program
I have written a JQuery program that, on the press of a button, runs
I have written an air app which is fixed in dimensions: 1000 w X
I have a program written in Java which involves massive amount of multidimensional array.
I have written a program in C# which connects to a POP Server and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.