C++ langugae only The first phase of compilation is called scanning or lexical analysis. This phase...

C++ langugae only

The first phase of compilation is called scanning or lexical analysis. This phase interprets the input program as a sequence of characters and produces a sequence of tokens, which will be used by the parser.

Your job is to write (in C++) a simple scanner for source code that obeys the language described below. You may assume that the input is syntactically correct.

Your program simply needs to read each token and then print out what type it is, based on the following language rules:

keyword -> if | then | else | begin | end | function | return identifier -> character | character identifier
integer -> digit | digit integer
real -> integer.integer

special -> + | - | = | < | >
digit -> 0|1|2|3|4|5|6|7|8|9 character -> a|b|c ... |z|A|B|C ... |Z

In: Computer Science

3. Mechanism of carbocation Rearrangements (hydride shift and methyl shift). Can you please explain what you...

3. Mechanism of carbocation Rearrangements (hydride shift and methyl shift).

Can you please explain

what you need to understand to do the mechanism

what possible reagents could be used

An example (how do you know that this is the mechanism you will use?)

Any tips/ tricks/videos to understanding this mechanism

In: Chemistry

The unemployments number of US for 2019 is 3.7%, and for the year 2010 is 9.7%...

The unemployments number of US for 2019 is 3.7%, and for the year 2010 is 9.7%

explain why we observe such a contrast.

In: Economics

1. some people are sensitive to aspirin. Why ? 2. relate excess aspirin inrake to a...

1. some people are sensitive to aspirin. Why ?
2. relate excess aspirin inrake to a peptic ulcer or a hole in the stomach lining.
3. what thoe of reaction is it that aids in aspirin's ability to stop more pain?
4. what if we didn't have ethanol for recrystallization? which alcohol could we use? more fhan one answer may be possible.
a.methanol
b.Isopropanol
c.n-propanol
d. n-butanol
5. we could have used sulfuric acid as a catalyst . Could we have use HCl? HNO3? why or why not?

In: Chemistry

Difference between Granovetter’s view of economic and Adam smith economic behavior theory?

Difference between Granovetter’s view of economic and Adam smith economic behavior theory?

In: Economics

three autosomal genes (Z, E and T) in seahorses. Each gene sorts independently and each gene...

three autosomal genes (Z, E and T) in seahorses. Each gene sorts independently and each gene has two alleles. The Z allele forms zebra stripes which are completely dominant over no stripes, z. The E allele codes for crossed eyes which is dominant over uncrossed eyes, e. Lastly, the T allele codes for jellyfish-like tentacles,which are dominant over (t) squid-like tentacles. You have two parents that are completely heterozygous for all traits. What is the probability they have offspring that have:

a.Zebra Stripes, uncrossed eyes, and squid-like tentacles? ________________

b.All dominant traits?_______________________________

c.Have the genotype ZZeeTt?_________________________

d.True breeding for zebra stripes, crossed eyes and squid-like tentacles?______________

e.All dominant alleles or all recessive alleles?________________

f.The first progeny is a male with zebra stripes and the second progeny is a male with no stripes?(assume sex probabilities in zebrafish is similar to humans)

In: Biology

Q1.      What additional concerns might a corporate Chief Financial Officer (CFO) face when a company expands...

Q1.      What additional concerns might a corporate Chief Financial Officer (CFO) face when a company expands into international markets?

(Ref: BMA, 13/e, Ch 1&12)

Answer:

Q2.      Fajer Inc., a retailer in the home improvement industry, currently operates seven retail outlets in Manama and Dubai. Management is contemplating building an eighth retail store across town from its most successful retail outlet. The company already owns the land for this store, which currently has an abandoned warehouse located on it. Last month, the marketing department spent $100,000 on market research to determine the extent of customer demand for the new store. Now Fajer Inc. must decide whether to build and open the new store.

            Which of the following should be included as part of the incremental earnings for the proposed new retail store?

a.   The cost of the land where the store will be located.

b.   The cost of demolishing the abandoned warehouse and clearing the lot.

c.   The loss of sales in the existing retail outlet, if customers who previously drove across town to shop at the existing outlet become customers of the new store instead.

d.   The $100,000 in market research spent to evaluate customer demand.

e.   Construction costs for the new store.

f.    The value of the land if sold.

g.   Interest expense on the debt borrowed to pay the construction costs.

(Ref: BMA, 13/e, Ch 5&6)

Answer:

Q3. Explain the similarities and differences between Net Present Value (NPV), Profitability Index (PI), and Economic Value Added (EVA).

(Ref: BMA, 13/e, Ch 5, 6, &12)

Answer:

       

Q4.      Which of the following bonds will have the greatest percentage increase in value if all interest rates decrease by 1 percent?

  • 10-year zero coupon bond.
  • 20-year zero coupon bond.
  • 20-year 10 percent coupon bond.
  • 20-year 5 percent coupon bond.
  • 1-year 10 percent coupon bond.

(Ref: BMA, 13/e, Ch 2)

Answer:

Q5.      The relationship between a bond’s yield to maturity and coupon interest rate can be used to predict its pricing level. For each of the bonds listed below, state whether the price of the bond will be at a premium to par, at par, or at a discount to par.

Bond

Coupon interest rate

Yield to maturity

Price

A

6%

10%

?

B

8%

8%

?

C

9%

7%

?

D

7%

9%

?

E

12%

10%

?

(Ref: BMA, 13/e, Ch 3)

Answer:

In: Finance

The objective of this experiment is to identify real world applications of quantum mechanics. Write a...

The objective of this experiment is to identify real world applications of quantum mechanics. Write a paper with a minimum of 1200 words discussing real world applications of quantum mechanics.

In: Chemistry

Java: Write a Java function to swap two integers.

  1. Java: Write a Java function to swap two integers.

In: Computer Science

​​​​​​In regards to Malware: Develop at least two open research questions and discuss why the problem...

​​​​​​In regards to Malware:

  • Develop at least two open research questions and discuss why the problem of each research question has remained unsolved and present the barriers to finding a solution. Do you find any partial solutions identified? If yes, do they work in part?
  • Discuss the goals of the research questions. Do you expect both questions to remain open over the coming few years? Why?

In: Computer Science

Should I give the Page Quality (PQ) rate of LOW or LOWEST? 1. True/False - A...

Should I give the Page Quality (PQ) rate of LOW or LOWEST?

1. True/False - A page with a mismatch between the location of the page and the rate location; for example an English (UK) page for an English (US) rating task.

I think it's false because of this statement in the general guidelines. Do not consider the country or location of the page or website for PQ rating. For example, English (US) raters should use the same PQ standards when rating pages from other English language websites (UK) as they use when rating pages from the U.S websites. In other words, English (US) raters should not lower the PQ rating because the page location (UK) does not match the task location.

2. True/False A file type other than a webpage, for example: a PDF, a Microsoft Word document, or a PNG file.

3. True/False A page that gets a Didn't Load flag.

4. True/False Pages with an obvious problem with functionality or errors in displaying content.

In: Computer Science

c++ code please show differint h files and cpp files 2.3 Task 1 You are working...

c++ code please

show differint h files and cpp files

2.3 Task 1

You are working as a programmer designing a vehicular system for the newly forced Edison Arms Company. The weapon system is a generic weapon housing that can fit a number of different weapons that are all controlled by a tank in the same way. Most importantly, is the emphasis on safety. During combat, the weapon systems cannot become unreliable or fail lest the pilots be put in unnecessary danger. The weapons generate heat which will also be a factor. Therefore you will need to provide mechanisms to combat this.

2.3.1 fireControl

This is the mounting system for the weapons. It can store a number of weapons and control them as well as handle problems. It is defined as follows:

fireControl
-weapons:weapon **
-numWeapons: int
---------------------------
+fireControl(numWeapons:int, weaponList: string *)
+~fireControl()
+accessWeapon(i:int):weapon *

The class variables are as follows:

  • weapons: A 1D array of weapon pointers. It must be able to accept any type of weapon defined in the hierarchy.

  • numWeapons: The number of weapons that are mounted into the system. The class methods are as follows:

  • fireControl: This is the constructor. It will receive a list of weapon names as a string array plus the number of weapons. It must allocate memory for the weapons variable and create a weapon based on the information provided by the string array. Create one weapon of the type indicated at each index of the array. If the name of the weapon contains missile, then a missile type weapon must be created and similarly for laser. This should not be case sensitive. For example given the string [”Laser Beam”, ”laser rifle”,”missile pod”, ”missiles”], 4 weapons would be created, the first two being of the class laser, and the last two of the class missile. The default strength for a laser weapon should be set to 5 when creating laser weapons.

  • ∼fireControl: The class destructor. It must deallocate all of the memory assigned to the class.

  • accessWeapon: This receives an int which provides an index in the weapons list. It will return the weapon that is stored at that position. If no such weapon is found there, then throw a weaponFailure exception.

    2.3.2 weaponFailure

  • This is a custom exception class used in the context of this system. It will inherit publicly from the exception class. You will need to override specifically the what method to return the statement ”Weapon System Failure!” without the quotation marks. The name of this class is weaponFailure. This exception will be used to indicate a failure of the weapon system. You will implement this exception in the fireControl class as a struct with public access. You will need to research how to specify exceptions due to the potential for a ”loose throw specifier error” and what clashes this might have with a compiler. Remember that implementations of classes and structs must be done in .cpp files.

As a hint, all of the exception structs in this practical will have three functions:

• A constructor
• a virtual destructor with a throw() specifier
• a const what function which returns a const char* with a throw() specifier.

2.3.3 ammoOut

This is a custom exception class used in the context of this system. It will inherit publicly from the exception class. You will need to override specifically the what method to return the statement ”Ammo Depleted!” without the quotation marks. The name of this class is ammoOut. This exception will be used to indicate a depletion of ammunition for a weapon. You will implement this exception in the weapon class as a struct with public access. You will need to research how to specify exceptions due to the potential for a ”loose throw specifier error” and what clashes this might have with a compiler. Remember that implementations of classes and structs must be done in .cpp files.

2.3.4 Weapon Parent Class
This is the parent class of laser and missile. Both of these classes inherit publicly from

it. It is defined according to the following UML diagram:

weapon
-ammo:int
-type:string
-name: string
-------------------
+weapon()
+weapon(a:int, t:string, n:string)
+getAmmo():int
+setAmmo(a:int):void
+getType():string
+setType(s:string):void
+getName():string
+setName(s:string):void
+ventWeapon(heat:T):void

+∼weapon()
+fire()=0:string
The class variables are as follows:

• ammo: The amount of ammo stored in the weapon. As it is fired, this will deplete. • type: The type of the weapon as a string which relates to its class.

The class methods are as follows:

  • weapon: The default class constructor.

  • weapon(a:int, t:string, n:string): The constructor. It will take three arguments and instantiate the class variables accordingly with name being the last variable set.

  • getAmmo/setAmmo: The getter and setter for the ammo.

  • getType/setType: The getter and setter for the type.

  • getName/setName: The getter and setter for the name.

  • ∼weapon: The destructor for the class. It is virtual.

  • fire: This is the method that will fire each of the weapons and produce a string of the outcome. It is virtual here.

  • ventWeapon: This is a template function. It will receive a generic parameter rep- resenting some amount of heat. When called the function should determine the number of cooling cycles needed for the weapon to cool based on the amount of heat that is passed in. For every 10 units of heat, 1 cycle will be needed. You need to display a number of lines of output (with new lines at the end) to represent this. For example, if there’s 50.83 heat passed or 50 heat passed in, the output should be:

         Heat Cycle 1
         Heat Cycle 2
         Heat Cycle 3
         Heat Cycle 4
         Heat Cycle 5
    

    Pay attention to the format of the output messages. If the heat is less than 10, then display with a newline at the end:

         Insufficient heat to vent
    

    2.3.5 laser

    The ionCannon is defined as follows:

    laser
    -strength:int
    ------------------------------
    +laser(s:int)
    +~laser()
    +setStrength(s:int):void
    +getStrength():int
    +fire():string
    

The class variables are as follows:
• strength: The strength of the laser. Lasers get stronger the longer they are fired.

The class methods are as follows:

  • laser: The class constructor. This receives an initial strength for the laser.

  • ∼laser: This is the destructor for the laser. It prints out ”X Uninstalled!” without the quotation marks and a new line at the end when the class is deallocated. X refers to the name of the weapon. For example:

         Tri Laser Cannon Uninstalled!
    
  • fire: If the laser still has ammo, it must decrease the ammo by 1. It will also increase the strength by 1. It will return the following string: ”X fired at strength: Y” where Y represents the strength before firing and X, the name of the weapon. Do not add quotation marks. If ammo is not available, instead throw the ammoOut exception.

  • getStrength/setStrength: The getter and setter for the strength variable. 2.3.6 missile

    The missile is defined as follows:

    missile
    ------------------------------
    +missile()
    +~missile()
    +fire():string
    

    The class methods are as follows:

    • missile: This is the constructor for the class.

    • ∼missile: This is the destructor for the missile. It prints out ”X Uninstalled!” without the quotation marks and a new line at the end when the class is deallocated. X refers to the name of the weapon. For example:

           Missile Rack Uninstalled!
      
    • fire: If the rifle still has ammo, it must decrease the ammo by 1. It will return the following string: ”X fired!”. X refers to the name of the weapon. Do not add quotation marks. If ammo is not available, instead throw the ammoOut exception.

      You should use the following libraries for each of the classes:
      • fireControl: iostream, string, sstream, algorithm, cstring, exception • weapon: string, iostream, exception, sstream

      Your submission must contain fire- Control.h, fireControl.cpp, laser.h, laser.cpp, missile.h, missile.cpp, weapon.h, weapon.cpp,main.cpp.

In: Computer Science

Suppose an economy under fixed (pegged) exchange rates is currently facing: a balanced current account (NX...

Suppose an economy under fixed (pegged) exchange rates is currently facing:

  • a balanced current account (NX = 0),

  • a negative output gap (excess unemployment), and

  • a balanced budget.

  • Using an NX/ (S-I) model depict the above situation in relation to the internal and external balance diagrammatically.

  • Now suppose as an advisor to the government your recommendation is to employ an expenditure-changing policy to attain the Internal Balance. Explain in details what this policy is made up and what the consequences of your recommendations will be. Show diagrammatically and explain fully.

  • In light of your answer above would you agree with this statement? “A trade deficit and low savings go hand in hand.” Evaluate fully.

  • Defend this proposition “attaining the two policy objectives of internal and external balance requires two polices”. Explain and illustrate diagrammatically.

In: Economics

1) Much of current all research is focused on replicating human thought in computers. What similarities...

1) Much of current all research is focused on replicating human thought in computers. What similarities exist between the human brain and computers that lead scientists to believe that this is a feasible endeavor? What differences complicate this type of research?

In: Computer Science

This is an assignment done using the terminal of linux. In this assignment, you will •...

This is an assignment done using the terminal of linux.

In this assignment, you will

• use make to modify a c++ program and

• gdb a debugging tool.

Part 1

From the course website (or the departmental dropbox) download the program source files for the project myname.

Part 2: myname program (5 points)

1. Using your favorite text editor, modify the source code to print out your name instead of mine when the binary file is executed. Hint: YOU ARE NOT ”THOMAS THE TANK ENGINE”

2. Modify the makefile to include a rule that creates a backup of the source files, makefile, and readme in an archive directory in your home directory structure.

Submit a compressed, archived tar file [yourUserID].assignment4_1.tar.[Z,gz] with your modified source code.

3. Use the gdb debugger to step through the program. Check to ensure the Makefile is modified to allow for debugging. Submit a text file [yourUserID].assignment4_2.txt containing the gdb output for the following sequence of commands:

gdb myname

start

step [issue this command until you get the “program exited normally” message]

quit

Submission This time, there should be two files that you are uploading

[yourUserID].assingment4_1.tar.[Z,gz] and [yourUserID].assingment4_2.txt

• When you have finished, submit the files using the departmental dropbox.

Here are the contents of CSCE215 directory that contains the program and files associated with it:

main.cpp

#include <iostream>
#include <string>
using namespace std;
#include "name.h"

int main () {
        name myName;

        myName.SetLast(LAST);
        myName.SetMiddle(MI);
        myName.SetFirst(FIRST);

        cout <<"My name is: ";
        myName.PrintFirst();
        myName.PrintMiddle();
        myName.PrintLast();
  
        return 0;
}

Makefile

# makefile to build a program

# program depends on components: name and main
myname:      main.o name.o
   g++ -g main.o name.o -o myname

# name.cpp has it's own header file
name.o:        name.cpp name.h
   g++ -c -g name.cpp

# main.cpp also uses the header file name.h
main.o:           main.cpp name.h
   g++ -c -g main.cpp

clean:
   /bin/rm -f myname *.o

name.cpp

#include <iostream>
#include <string>
using namespace std;
#include "name.h"

void name::GetFirst(string str) {
   str=first;
}

void name::SetFirst(string str) {
   first=str;
}

void name::GetMiddle(string str) {
   str=middle;
}

void name::SetMiddle(string str) {
   middle=str;
}

void name::GetLast(string str) {
   str=last;
}

void name::SetLast(string str) {
   last=str;
}

void name::PrintLast() {
   cout << last << "\n";
}
void name::PrintMiddle() {
        cout << middle;
}
void name::PrintFirst() {
        cout << first;
}

name.h

#define LAST   "tankengine"
#define MI   "the "
#define FIRST   "thomas "

class name {

   private:
   string first;
   string middle;
   string last;
  
   public:
   void SetFirst(string str);
   void GetFirst(string str);
  
   void SetMiddle(string str);
   void GetMiddle(string str);
  
   void SetLast(string str);
   void GetLast(string str);

   void PrintLast();
   void PrintMiddle();
   void PrintFirst();
  
};

readme

/*
Copyright: 2005, All rights reserved.
Program: myname
Version: 1.1
Created: 9/6/05
Revised: 1/22/09
Files: name.cpp, name.h, main.cpp, Makefile
Programmer: Patrick O'Keefe who gratefully acknowledges Dr. Jason Bakos's kind assistance.
Course: CSCE-215
Assignment: Class Project
Compiler: GNU Gcc version 4.2.3
Target: Linux

Description:

This program attempts string assigment. and other stuff....

Revisions:

There have been no major revisions of this program.

Constants and Variables:

See code for constant and variable descriptions.
or
you could put that kind of info here. Like:
   FIRST -> your first name
   MIDDLE -> ditto
   LAST -> and ditto.
ok here is a change.

ALL OF THOSE FILES ARE LOCATED IN A DIRECTORY /CSCE215


In: Computer Science