I Have To Code In C And I M Given These Files Project 2

I have to code in c++, and I’m given these files

project 2.cc

/*

 * Copyright (C) Mohsen Zohrevandi, 2017

 *

 * Do not share this file with anyone

 */

#include <iostream>

#include <cstdio>

#include <cstdlib>

using namespace std;

int main (int argc, char* argv[])

{

   int task;

   if (argc < 2)

   {

       cout << “Error: missing argumentn”;

       return 1;

   }

   /*

      Note that by convention argv[0] is the name of your executable,

      and the first argument to your program is stored in argv[1]

    */

   task = atoi(argv[1]);

   // TODO: Read the input grammar at this point from standard input

   /*

      Hint: You can modify and use the lexer from previous project

      to read the input. Note that there are only 4 token types needed

      for reading the input in this project.

      WARNING: You will need to modify lexer.cc and lexer.h to only

      support the tokens needed for this project if you are going to

      use the lexer.

    */

   switch (task) {

       case 1:

   cout << “decl idList idList1 colon ID COMMA n”;

           break;

       case 2:

           // TODO: perform task 2.

           break;

       case 3:

           // TODO: perform task 3.

           break;

       case 4:

           // TODO: perform task 4.

           break;

       case 5:

           // TODO: perform task 5.

           break;

       default:

           cout << “Error: unrecognized task number ” << task << “n”;

           break;

   }

   return 0;

}

———————————————————————————————–

lexer.h

#ifndef __LEXER__H__

#define __LEXER__H__

#include <vector>

#include <string>

#include “inputbuf.h”

// Lexer modified for FIRST & FOLLOW project

typedef enum { END_OF_FILE = 0, ARROW, HASH, DOUBLEHASH, ID, ERROR } TokenType;

class Token {

 public:

   void Print();

   std::string lexeme;

   TokenType token_type;

   int line_no;

};

class LexicalAnalyzer {

 public:

   Token GetToken();

   TokenType UngetToken(Token);

   LexicalAnalyzer();

 private:

   std::vector<Token> tokens;

   int line_no;

   Token tmp;

   InputBuffer input;

   bool SkipSpace();

   Token ScanId();

};

#endif //__LEXER__H__

———————————————————————————————–

lexer.cc

#include <iostream>

#include <istream>

#include <vector>

#include <string>

#include <cctype>

#include “lexer.h”

#include “inputbuf.h”

using namespace std;

// Lexer modified for FIRST & FOLLOW project

string reserved[] = { “END_OF_FILE”, “ARROW”, “HASH”, “DOUBLEHASH”, “ID”, “ERROR” };

void Token::Print()

{

   cout << “{” << this->lexeme << ” , “

        << reserved[(int) this->token_type] << ” , “

        << this->line_no << “}n”;

}

LexicalAnalyzer::LexicalAnalyzer()

{

   this->line_no = 1;

   tmp.lexeme = “”;

   tmp.line_no = 1;

   tmp.token_type = ERROR;

}

bool LexicalAnalyzer::SkipSpace()

{

   char c;

   bool space_encountered = false;

   input.GetChar(c);

   line_no += (c == ‘n’);

   while (!input.EndOfInput() && isspace(c)) {

       space_encountered = true;

       input.GetChar(c);

       line_no += (c == ‘n’);

   }

   if (!input.EndOfInput()) {

       input.UngetChar(c);

   }

   return space_encountered;

}

Token LexicalAnalyzer::ScanId()

{

   char c;

   input.GetChar(c);

   if (isalpha(c)) {

       tmp.lexeme = “”;

       while (!input.EndOfInput() && isalnum(c)) {

           tmp.lexeme += c;

           input.GetChar(c);

       }

       if (!input.EndOfInput()) {

           input.UngetChar(c);

       }

       tmp.line_no = line_no;

       tmp.token_type = ID;

   } else {

       if (!input.EndOfInput()) {

           input.UngetChar(c);

       }

       tmp.lexeme = “”;

       tmp.token_type = ERROR;

   }

   return tmp;

}

// you should unget tokens in the reverse order in which they

// are obtained. If you execute

//

//   t1 = lexer.GetToken();

//   t2 = lexer.GetToken();

//   t3 = lexer.GetToken();

//

// in this order, you should execute

//

//   lexer.UngetToken(t3);

//   lexer.UngetToken(t2);

//   lexer.UngetToken(t1);

//

// if you want to unget all three tokens. Note that it does not

// make sense to unget t1 without first ungetting t2 and t3

//

TokenType LexicalAnalyzer::UngetToken(Token tok)

{

   tokens.push_back(tok);;

   return tok.token_type;

}

Token LexicalAnalyzer::GetToken()

{

   char c;

   // if there are tokens that were previously

   // stored due to UngetToken(), pop a token and

   // return it without reading from input

   if (!tokens.empty()) {

       tmp = tokens.back();

       tokens.pop_back();

       return tmp;

   }

   SkipSpace();

   tmp.lexeme = “”;

   tmp.line_no = line_no;

   input.GetChar(c);

   switch (c) {

       case ‘-‘:

           input.GetChar(c);

           if (c == ‘>’) {

               tmp.token_type = ARROW;

           } else {

               if (!input.EndOfInput()) {

                   input.UngetChar(c);

               }

               tmp.token_type = ERROR;

           }

           return tmp;

       case ‘#’:

           input.GetChar(c);

           if (c == ‘#’) {

               tmp.token_type = DOUBLEHASH;

           } else {

               if (!input.EndOfInput()) {

                   input.UngetChar(c);

               }

               tmp.token_type = HASH;

           }

           return tmp;

       default:

           if (isalpha(c)) {

               input.UngetChar(c);

               return ScanId();

           } else if (input.EndOfInput())

               tmp.token_type = END_OF_FILE;

           else

               tmp.token_type = ERROR;

           return tmp;

   }

}

———————————————————————————————–

inputbuf.h

#ifndef __INPUT_BUFFER__H__

#define __INPUT_BUFFER__H__

#include <string>

class InputBuffer {

 public:

   void GetChar(char&);

   char UngetChar(char);

   std::string UngetString(std::string);

   bool EndOfInput();

 private:

   std::vector<char> input_buffer;

};

#endif //__INPUT_BUFFER__H__

———————————————————————————————–

inputbuffer.cc

#include <iostream>

#include <istream>

#include <vector>

#include <string>

#include <cstdio>

#include “inputbuf.h”

using namespace std;

bool InputBuffer::EndOfInput()

{

   if (!input_buffer.empty())

       return false;

   else

       return cin.eof();

}

char InputBuffer::UngetChar(char c)

{

   if (c != EOF)

       input_buffer.push_back(c);;

   return c;

}

void InputBuffer::GetChar(char& c)

{

   if (!input_buffer.empty()) {

       c = input_buffer.back();

       input_buffer.pop_back();

   } else {

       cin.get(c);

   }

}

string InputBuffer::UngetString(string s)

{

   for (unsigned i = 0; i < s.size(); i++)

       input_buffer.push_back(s[s.size()-i-1]);

   return s;

}

———————————————————————-

Please help. I have no clue at the moment,

Im only asking for case 1.

I can figure out the rest.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

I Have To Write An Essay And Need Help With An Outline For My Business Law Class

I have to write an essay and need help with an outline for my business law class. The question for the assignment is… Few issues more pointedly divide Democrats and Republicans than the issue of economic regulation. The GOP has long held that the effective functioning of a market economy depends heavily on a lack of regulation of the economy – so that the “Invisible Hand” of Adam Smith might be able to allow companies to succeed or fail without interference by government. Republicans argue that market forces should be the prime determinant of commercial activity and individual entrepreneurship.In contrast, Democrats have traditionally argued that a market economy necessarily creates “winners” and “losers,” and that government has a responsibility to mitigate the harms to those who are negatively impacted by cyclical economic forces. Democrats also have promoted and enacted strong regulatory mechanisms that provide oversight of companies, especially concerning public health and public safety issues.To what extent should government intervene in the economy? Are there limits to governmental oversight of corporations? Does regulation diminish the ability of businesses to thrive and compete in the global marketplace?

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

I Have To Make A 2500 Essay On Project Management I Have Started Off By Giving A

I have to make a 2500 essay on Project Management. I have started off by giving a small intro to PM but now I am stuck on describing the background of the project. I don’t understand what a paragraph of ‘background of the project’ means?

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

I Have To Write An 800 Word Paper On Having My Own Business Defining On How You

I have to write an 800-word paper on having my own business  

Defining on how you will be a more effective manager, leader or overall person by integrating key elements of the principles of management course in your professional and personal life. Your paper should address questions like the following:

What obstacles have you identified that have prevented you from being as successful as you want to be?

What plan of action will you make to remove those obstacles?

What impact will they have on the organization you expect to work in now or in the future?

What elements in this course, if any, most impacted you and why?

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

I Have To Identify Two Researchable Problems Related To Business Organizational

I have to identify two researchable problems related to business organizational leadership.

Is leadership among women a related researchable problems related to business organizational leadership. I am not sure what another one would be.

I have to give a brief summary of each problem to establish its context and relevance. What is meant by the summary is this what I think is the problem?

I then need to have a null hypothesis (H0) and a research hypothesis (H1) for each problem based on the following conditions:

One research hypothesis must be one-tailed.How am I going to know which is one and which is two. Do I fisrt look for this before the research question

One research hypothesis must be two-tailed.

Not sure how to attack this. What would I do first? Do I try and find a problem liker leadership with women or what?

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

I Have To Write An 8 Page Literature Review Paper About Workplace Training Progr

I have to write an 8 page literature review paper about workplace training programs. Where do I begin? How should it be structured? Do you have any examples? I obviously can’t just copy and past as the University utilizes “Safe Assign” nor would I want to copy/paste. However, an example would be great.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

I Have To Explain About The Cash Flow Statement For Gsk The Directions Are Your

I just want to know if I answered all the questions.

Professor Shihong Li:

    This letter is to address the GlaxoSmithKline plc cash flow statement and to explain and answer the questions of what reporting standard is used, how the company’s ability to generate cash has been changing over the past three years, what the major uses and sources of cash during the past three years and whether the reporting would be different using GAAP and why.

     GSK uses IFRS (International Financial Reporting Standards) rather than GAAP (Generally Accepted Accounting Principles). which is used in the U.S. Interest received or paid is reported as operating activities where IFRS records interest received as investing and interest paid is reported as financing. Dividends received are classified as operating activities in GAAP but IFRS reports them in investing. Dividends paid are classified as financing activities in GAAP but in IFRS receiving dividends are reported as investing and dividend payout is financing. GSK uses pounds in million in their financial statements. There are similarities between the IFRS and FAAP they both can use indirect and direct methods for the cash flow and they must both use operating, finance and investing activities for either method. GSK reports their Bank overdrafts in cash equivalents in the operating activities but under GAAP these are a liability. 

       The cash flow from operations increased by 40% from 2015 to 2016 and 6% from 2016 to 2017. The 6 % change from 2016 to 2017 is due to the purchasing of inventory in advance of the new products. The cash flow from investing for 2015 to 2016 decreased -4.1 but this was due to the disposal of businesses in 2015 with a gain of 10,246. Other than the impact of depreciation, the following should be considered; inventories have increased so cash decreased, payables increased which means GSK is retaining cash.   

      As can be seen by the following chart profit decreased in 2016 from 2015 by 87%. In .2017 profit increased from 2016 by 49%.   Depreciation increased from 2015 to 2017 by 10% which is caused by the depreciating of new equipment. Intangible assets amortization increased from 2015 to 2017 to 21% because of the businesses purchased, you also have patents and goodwill is also increased. Asset s written off has increased 23% due to the disposing of business assets. The loss on sale of businesses has dropped from (9308) in 2015 to (157) in 2017. Although they did not make a profit on the sale of the businesses, they will still receive royalties as a joint venture. As you can see they have increased inventories in advance of new products to be manufactured which should increase profits in the future. 

 The free cash flow for 2015 was (235) which shows that in 2015 they could not pay their payables but there were considerable restructuring costs. The free cash flow for 2016 was 3629 which means they can now pay their current liabilities and invest. There is a 5% decrease in 2017 free cash flow, but they did pay a short-term loan off. The payment of interest and tax are covered by cash generated from operations. The major source of operating cash inflow is sustainable therefore GSK is in a positive position. The operating cash inflow is aided by smaller cash inflow from the sale of small businesses and the issue of shares. These cash flows are not sustainable. The assets purchased will be used to generate cash for future years. The 3200 used to pay off a short-term loan will make it a less risky investment. The size of dividends is a cause for concern although they did decrease every year. In 2015, at 3874 million pounds, they represent 84% of the cash generated from operations. In 2016, at 4850 million pounds, they represent 60% of the cash generated from operations. In 2017, at 3906 million pounds, they represent 47% of the cash generated from operations. This seems to be a high distribution percentage and makes me think why they are returning such large amounts to the shareholders when in 2017 they took out a new long-term loan.

         GSK’s cash flows would change in the following matter if they used GAAP instead of IFRS, because the net cash flow for operations in 2016 would change from 6918 million pounds to 4812 million pounds due to the addition of interest paid that would be deducted from investments and added to operations, interest received would be taken from finance and added to operations. Dividends received would be taken from investments and added to operations. Bank overdrafts would be in liabilities instead of cash equivalents. Disposal of businesses would not be in investing but in operations. Overall totals would not change except bank overdrafts would be added back into cash equivalents. The net cash outflow from operating, investing, and financing activities if using GAAP for 2017 is (672) million pounds, for 2016 it is (872) million pounds and in 2015 is 1847 million pounds.

Sincerely,

Sherry Kelly

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

I Have To Write A Written Project In Apa Style Attached Is The Outline And Examp

I have to write a written project in APA style attached is the outline and example our the paper you should follow.  The Topic of my written project is “Global Warming” no more than 8 pages including the references.

Thank you

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

I Have To Do An Annotated Bibliography On The Book Sparing Nature The Conflict B

I have to do an Annotated Bibliography on the book, Sparing Nature, The Conflict Between Human Population Growth and Earth’s Biodiversity. I just need help with five sources from peer reviewed journals.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

I Have To Write A Visual Rhetorical Analysis Paper Over A Political Cartoon Of M

I have to write a Visual Rhetorical Analysis paper over a political cartoon of my choice (abortion). https://www.mercurynews.com/ 

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW