Questions
Continue performing the steps in this appendix, starting with the section called Developing the Schedule. Print...

Continue performing the steps in this appendix, starting with the section called Developing the
Schedule. Print out the following screens or send them to your instructor, as directed:
a. Figure A-32. All task durations and recurring task entered
b. Figure A-39. Network diagram view
c. Figure A-46. Changing Work hours for tasks
d. Figure A-56. Earned value report
e. Continue performing the steps, or at least read them. Write a one-to-two page paper
describing the capabilities of Project Professional 2016 and your opinion of this software.
What do you like and dislike about it?

In: Computer Science

Write a program that will input the information for 2 different employees. Prompt the user for...

Write a program that will input the information for 2 different employees. Prompt the user for the first employee’s name, hours worked and rate. Compute the salary and display it. Do the same for the second and third employees. Then, display a message to the effect that the highest salary is whatever and the lowest salary is whatever. When the program runs, the following should display information should line up just as I have it below. E:\> java Quiz4 Name:

John Doe Class: CSCI 1250-001 (or 002) Date: September 18, 2019 Program: Quiz4.java First Employee:

John Smith Hours Worked: 40.0 Rate of pay: 10.0 Salary for John Smith is $400.00

Second Employee:

Sarah Jones Hours worked: 30.0 Rate of pay: 7.50 Salary for Sarah Jones is $225.00

Third Employee: Andrew Johnson Hours Worked: 31.5 Rate of pay: 10.75 Salary for Andrew Johnson is $338.63

The largest salary is $400.00 The smallest salary is $225.00

In: Computer Science

Given this class: class Issue { public:                 string problem; int howBad; void setProblem(string problem); };...

Given this class:

class Issue

{

public:

                string problem;

int howBad;

void setProblem(string problem);

};

And this code in main:

vector<Issue> tickets;

Issue issu;

a)

tickets.push_back(-99);

State whether this code is valid, if not, state the reason

b)

Properly implement the setProblem() method as it would be outside of the class. You MUST name the parameter problem as shown in the prototype like:

(string problem)

c)

Write code that will output the problem attribute for every element in the tickets vector. The code MUST work for no matter how many elements are contained in tickets. The output should appear as:

Problem #1 is the problem attribute in element 1.

Problem #2 is the problem attribute in element 2.

In: Computer Science

Write a java code to demonstrate the File IO. Your code should get the following information...

Write a java code to demonstrate the File IO. Your code should get the following information from the user.

• Get a file name fname for output • Get number of data (numbers) (N) you want to process from the user

• Get N numbers from the users through keyboard and store them in an array

• Get M (How many numbers to read from file)

• (Or)You are free to use same N for M (use N for both purposes) You have to define two methods:

1) To write the numbers from the array into the file fname

2) To read numbers from the file fname, store them in an array, and compute average of the numbers.

The method should display the numbers from the array and the average value.

In: Computer Science

Please identify each of the requirements as a functional requirement/property or non-functional requirement/property. For every non-functional...

Please identify each of the requirements as a functional requirement/property or non-functional requirement/property. For every non-functional property/requirement, please add a remark to explain why.

1. Customers must provide shipping information.

2. The system allows customers to pay with a Pay Pal account or a valid credit card on a web browser of their choice.

3. Customers must first register and set up an account with the system before they can purchase items.

4. In order to register an account, customers must have a valid e-mail address.

5. Customers must create a password and provide personal answers to account security questions.

6. Customers may have their credit card information saved to their account for faster use in the future.

7. Customers have the choice of splitting up a payment into multiple smaller payments.

8. Once an order is completed, the customer receives a confirmation number.

9. Upon receipt of the payment, the confirmed order is assigned with a tracking number.

10. The bookstore manager will be able to access the system in order to view sales summary reports.

In: Computer Science

What can be said about baseline data and ABABA design

What can be said about baseline data and ABABA design

In: Computer Science

**Only need the bold answered In Java, implement the Athlete, Swimmer, Runner, and AthleteRoster classes below....

**Only need the bold answered

In Java, implement the Athlete, Swimmer, Runner, and AthleteRoster classes below. Each class must be in separate file. Draw an UML diagram with the inheritance relationship of the classes.

1. The Athlete class
a. All class variables of the Athlete class must be private.

b.is a class with a single constructor: Athlete(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender). All arguments of the constructor should be stored as class variables. There should only be getter methods for first and last name variables. There should be no getters or setters for birthYear, birthMonth, birthDay.

c. Getter and setter methods for the gender of the athlete. The method setGender accepts a character and store it as a class variable. Characters 'm', 'M' denotes male, 'f' or 'F' denotes male or female. Any other char will be treated as undeclared. The method getGender return either the word "male" or "female" or “undeclared”.

  1. The method computeAge() takes no arguments and returns the athletes computed age (as of today's date) as a string of the form "X years, Y months and Z days". Hint: Use the LocalDate and Period classes.

    i. e.g. "21 years, 2 months and 3 days". ii. e.g. "21 years and 3 days".

    iii. e.g. "21 years and 2 months". iv. e.g. "21 years".

    v. e.g. "2 months and 3 days".

  2. The method public long daysSinceBirth() takes no arguments and returns a long which is the number of days since the athlete’s date of birth to the current day. Hint: Use the LocalDate and ChronoUnit classes.

  3. The toString method returns a string comprised of the results ofgetFname, getLName and computeAge. E.g.

    i. “Bunny Bugs is 19 years and 1 day old”

  4. The equals method returns true if the name and date of birth of this athlete and the compared other athlete are the same, otherwise return false.

2. The Swimmer class
a. All class variables of the Swimmer class must be private.

  1. inherits from the Athlete class and has a single constructor,

    Swimmer(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender, String team). There should be a class variable for team. There should be a getter method for team.

  2. The Swimmer class stores swim events for the swimmer. There should be a class variable for events. A swimmer participates in one or more of these events. The addEvent method is oveloadedand either adds a single event for the swimmer public boolean addEvent(String singleEvent) or adds a group of events for the swimmer public boolean addEvent(ArrayList multiEvents). Each event is of type String. Duplicate events are not stored and return false if duplicate found.

  3. There should be a getter method that returns the class variable events.

  4. The overridden toString method returns a string comprised of the concatenation of the parent’s toString return plus " and is a swimmer for team: XXXXX in the following events: YYYYY; ZZZZZZ." E.g.

    i. “Missy Franklin is 24 years and 4 months old and is a swimmer for team: Colorado Stars. She participates in the following events: [100m freestyle, 100m backstroke, 50m backstroke]”

3. The Runner class
a. All class variables of the Runner class must be private.

  1. inherits from the Athlete class and has a single constructor,

    Runner(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender, String country). There should be a class variable for country. There should be a getter method for country.

  2. The Runner class stores race events for the runner. There should be a class variable for events. Each event is a Distance. The list of valid events is given below:
    M100, M200, M400, M3000, M5000, M10000. A runner participates inone or more of these events. The addEvent method is oveloadedand either adds a single event for the runner public boolean addEvent(String singleEvent) or adds a group of events for the runner public boolean addEvent(ArrayList multiEvents). Each event is of type String. Duplicate events are not stored and return false if duplicate found.

  1. There should be a getter method that returns the class variable events.

  2. The toString method returns a String in the form: " AAA BBBB is XX years, YY months and ZZ days. He is a citizen of CCCCCCC and is a DDDDDDDD who participates in these events: [MJ00, MK00, ML00]”. If she does not participate in M3000 or M5000 or M10000 then she is a sprinter. If she does not participate in M100 or M200 or M400 then she is a long-distance runner. Otherwise she is a super athlete. E.g.

    i. “Bunny Bugs is 19 years and 1 day old. His is a citizen of USA and is a long-distance runner who participates in these events: [M10000]”

4. The AthleteRoster class
a. All class variables of the AthleteRoster class must be private.

  1. Does not inherits from the Athlete class. The AthleteRoster class has a single constructor, AthleteRoster(String semster, int year). There should be class variables for semester and year. There should be getter methods for semester and year.

  2. The AthleteRoster class has only one method for adding Athlete to the roster, by using the boolean addAthlete(Athlete a)method. The method returns true if the athlete was added successfully, it returns false if the athlete object already exists in the roster and therefore was not added.

  3. Your AthleteRoster class will have only one class level data structure, an ArrayList, for storing athlete objects.

  4. The String allAthletesOrderedByLastName() method returns a string object with of all the names of the athletes (Swimmers, Runners, etc.) in ascending order of last names(a-z).

  5. The String allAthletesOrderedByAge() method returns a string object with of all the names of the athletes (Swimmers, Runners, etc.) in descending order of age(100-0).

  6. The String allRunnersOrderedByNumberOfEvents() method returns a string object with of all the names of the Runners only in ascending order of number of events they participate in (0-100).

Here is the driver:

import java.util.ArrayList;
import java.util.Arrays;

public class AthleteDriver {
   public static void main(String args[]) {

       //Check Athlete Class
       Athlete a1 = new Athlete("Daffy","Duck", 2000, 9, 7,'j'); System.out.println("Gender is "+a1.getGender());//undeclared
       a1.setGender('F');
       System.out.println("Gender is "+a1.getGender());//female
       a1.setGender('m');
       System.out.println("Gender is "+a1.getGender());//male
       System.out.println("ComputeAge method says "+a1.computeAge());
       System.out.println("First name is : "+a1.getFname()); //Daffy
       System.out.println("DaysSinceBirth method says "+a1.daysSinceBirth()+" days"); System.out.println("Last name is : "+a1.getLname()); //Duck
       System.out.println("Output of our toString correct?: \n"+a1);
       System.out.println("=======================================\n");

       //Check Runner Class
       Runner r5 = new Runner("Bugs","Bunny", 2000, 9, 8, 'm',"USA");
       System.out.println("Did we add M10000 successfully?: "+r5.addEvent("M10000")); //true
       System.out.println("Did we unsucessfully try to add M10000 again?: "+r5.addEvent("m10000")); //false
       ArrayList<String> temp = new ArrayList<String>(Arrays.asList("M100", "M3000"));
   System.out.println("Did we successfully add mutiple events?: "+r5.addEvent(temp));//true
       System.out.println("Did we unsucessfully try to add mutiple events?: "+r5.addEvent(temp));//false
       System.out.println("How many events does Bugs participate in?: "+r5.getEvents().size());//3
       System.out.println("Gender is "+r5.getGender());//male
       System.out.println("Output of our toString correct?: \n"+r5);
       System.out.println("=======================================\n");

       //Check Swimmer Class
       Swimmer s1 = new Swimmer("Franklin", "Missy", 1995, 5, 10, 'F', "Colorado Stars");
       System.out.println("Did we add 100m backstoke successfully?: "+s1.addEvent("100m backstoke")); //true
       System.out.println("Did we unsucessfully try to add 100m backstoke again?: " +s1.addEvent("100M Backstoke")); //false
       temp = new ArrayList<String>(Arrays.asList( "200m backstoke","200m freestyle"));
       System.out.println("Did we successfully add mutiple events?: "+s1.addEvent(temp));//true
       System.out.println("Did we unsucessfully try to add mutiple events?: "+s1.addEvent(temp));//false
       System.out.println("How many events does s1 participate in?: "+s1.getEvents().size());//4 System.out.println("Gender is "+s1.getGender());//female
       System.out.println("Output of our toString correct?: \n"+s1);
       System.out.println("=======================================\n");

       //Check AthleteRoster
       Swimmer s2 = new Swimmer("Ruele", "Naomi", 1997, 1, 13, 'F',"Florida International University");
   //   s2.addEvent(newArrayList<String>(Arrays.asList("100m backstoke","50m backstoke","100m freestyle")));

   //   Runner r1 = new Runner("Bolt", "Usain", 1986, 8, 21, 'M',"Jamaica");
//       r1.addEvent("M100"); r1.addEvent("M200");

   //   Runner r2 = new Runner("Griffith", "Florence", 1959, 12, 21, 'F',"United States of America"); r2.addEvent("M100"); r2.addEvent("M200");
   //   r2.addEvent("M400"); r2.addEvent("M10000"); r2.addEvent("M3000");
   //   r2.addEvent("M5000");

   //   AthleteRoster ar = new AthleteRoster("Fall",2019);
   //   ar.addAthlete(a1);
   //   ar.addAthlete(s1);
   //   ar.addAthlete(r1);
   //   ar.addAthlete(r2);
   //   ar.addAthlete(s2);
   //   ar.addAthlete(r5);
   //   System.out.println(ar.allRunnersOrderedByNumberOfEvents());
       System.out.println("=======================================\n");

   //   System.out.println(ar.allAthletesOrderedByAge());
       System.out.println("=======================================\n");

   //   System.out.println(ar.allAthletesOrderedByLastName());
       System.out.println("=======================================\n");


   }

}

Complete the code before the due date. Submission of the completed eclipse project is via github link posted on the class page. Add your UML drawing to the github repo. ________________________________________________________________________ Example output:

__________Example from AthleteDriver shown below

Gender is undeclared
Gender is female
Gender is male
ComputeAge method says 19 years and 4 days
First name is : Duck

DaysSinceBirth method says 6943 days Last name is : Daffy
Output of our toString correct?:
Duck Daffy is 19 years and 4 days old =======================================

Did we add M10000 successfully?: true
Did we unsuccessfully try to add M10000 again?: false
Did we successfully add multiple events?: true
Did we unsuccessfully try to add multiple events?: false
How many events does Bugs participate in?: 3
Gender is male
Output of our toString correct?:
Bunny Bugs is 19 years and 3 days old. His is a citizen of USA and is a super athlete who participates in these events: [M10000, M100, M3000] =======================================

In: Computer Science

Write a program in Java that reads an input text file (named: input.txt) that has several...

Write a program in Java that reads an input text file (named: input.txt) that has several lines of text and put those line in a data structure, make all lowercase letters to uppercase and all uppercase letters to lowercase and writes the new lines to a file (named: output.txt).

In: Computer Science

The problem is below. This is for an intro to Python class, so, if possible keep...

The problem is below. This is for an intro to Python class, so, if possible keep it relatively simple and 'basic.'

The code in bold below is given:

def trade_action(current_stock, purchase_price, current_price, investment):
# Write your code here.
return "Hold Shares."

Instructions:

Many investment management companies are switching from manual stock trading done by humans to automatic stock trading by computers. You've been tasked to write a simple automatic stock trader function that determines whether to buy, sell, or do nothing (hold) for a particular account. It should follow the old saying "Buy low, sell high!"

This function takes 4 input parameters in this order:

  1. current_shares - current number of shares of this stock in the account (int).
  2. purchase_price - price (per share) paid for current stock in the account (float).
  3. market_price - current market price (per share) of stock in the account (float).
  4. available_funds - maximum amount the client is willing to spend on a stock purchase (float).

Any transaction (buy or sell) costs $10. This $10 must be paid out of the available_funds for a purchase, or out of the proceeds of a stock sale. Be sure to account for this fee in your profit calculations.

A purchase would be considered profitable when the current market price is lower than the purchase price, and the available funds will allow us to buy enough shares so that the difference in value will cover the $10 transaction fee. In this case the function should return the string "Buy # shares" where # is an integer representing the number of shares to purchase.

A sale would be considered profitable when the current market price is higher than the purchase price, and the value gained by selling the shares will cover the $10 transaction fee. In this case the function should return the string "Sell # shares" where # is an integer representing the number of shares to sell.

If neither a buy nor a sell would be profitable, then the function should return the string "Hold shares."

Here are some test cases that your function should satisfy:  

Test 1 Test 2 Test 3 Test 4 Test 5 Test 6
current_shares 10 20 15 1 10 1
purchase_price 100 2 12 1 1 1
market_price 1 1 1 11 3 12
available_funds 10 21 12 0 30 0
OUTPUT Hold shares Buy 11 shares Buy 2 shares HoldShares Sell 10 shares Sell 1 shares

Rationale for test cases:

Test 1
Even though the current market price is very low (compared to the purchase price), after paying the $10 transaction fee, we would not have any funds left to buy shares; so we can only hold.

Test 2
After paying the $10 transaction fee, there are enough funds remaining to buy 11 shares. At a purchase_price vs. market_price difference of $1 per share, our 11 shares represent a value gain of $11 dollars, which is $1 more than the $10 transaction fee - so we come out $1 ahead.

Test 3
After paying the $10 transaction fee, there are enough funds remaining to buy 2 shares. At a purchase_price vs. market_price difference of $11 per share, our 2 shares represent a value gain of $22 dollars, which is $12 more than the $10 transaction fee - so we come out $12 ahead.

Test 4
Selling our 1 share for $11 will leave us with just $1 after we pay the $10 transaction fee. That is the same as what we paid for it, and we won't make any profit - so we should hold.

Test 5
With a market_price vs. purchase_price vs. difference of $2 per share, we stand to make $20 from the sale of our 10 shares. This is $10 more than the price of the transaction fee, so we will come out $10 ahead - therefore we should sell all 10 shares.

Test 6
Our 1 share is worth $11 more than we paid for it at the current market price. The $11 dollars obtained by selling that share now will still leave us with a profit of $1 after paying the $10 transaction fee. Profit is profit, so we should sell.

Things to think about when you’re designing and writing this program:

  1. Look for opportunities to use variables as a way to name things, and to break larger more complex expressions down into simpler expressions.
  2. Spend some time choosing your names carefully. Names should be descriptive.
  3. Try to design and write your code a few lines at a time. Design and write a few lines, then run some tests to see if these lines are doing what you want them to do. If they are not, then analyze and correct them before you move on to the next few lines of code.

In: Computer Science

Need someone to rewrite this code to work in the same way: int testScore;    //Numeric test...

Need someone to rewrite this code to work in the same way:

int testScore;    //Numeric test score

        String input;     //To hold the user's input

       

        // Get the numeric test score.

        input = JOptionPane.showInputDialog("Enter your numeric test score and I will tell you the grade: ");

        testScore = Integer.parseInt(input);

       

        //Display the grade.

        if (testScore < 60)

           JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is an F.");

        else if (testScore < 70)

           JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is a D.");

        else if (testScore < 80)

           JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is a C.");

        else if (testScore < 90)

           JOptionPane.showMessageDialog(null, "Your score of "+testScore+"e is a B.");

        else

           JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is an A.");

    }

   

}

Need ans asap......

In: Computer Science

I was wondering if you can tell me if the following code is correct and if...

I was wondering if you can tell me if the following code is correct and if its not can it be fixed so it does not have any syntax errors.

Client one

/**
* Maintains information on an insurance client.
*
* @author Doyt Perry/<add your name here>
* @version Fall 2019
*/
public class Client
{
// instance variables
private String lastName;
private String firstName;
private int age;
private int height;
private int weight;

/**
* First constructor for objects of class Client.
*/
public Client()
{
// initialize all instance variables to placeholder values
this.lastName = "last name";
this.firstName = "first name";
this.age = 0;
this.height = 1;
this.weight = 1;
}

/**
* Second constructor for objects of class Client.
*
*
* Create a client object using explicit parameters to specify
* values for corresponding instance fields.
*
* @param inLastName last Name of client
* @param inFirstName first Name of client
* @param inAge age of client
* @param inHeight height of client
* @param inWeight weight of client
*/
public Client(String inLastName, String inFirstName, int inAge,
int inHeight, int inWeight)
{
// initialize instance variables
// using values passed in as parameters
this.lastName = inLastName;
this.firstName = inFirstName;
this.age = inAge;
this.height = inHeight;
this.weight = inHeight;
}


/**
* Update the last name of the client.
*
* @param inLastName last name of the client.
*/
public void setLastName(String inLastName)
{
// Set the last name instance variable to parameter
this.lastName = inLastName;
}
  
/**
* Return the last name of the client.
*
* @return String last name.
*/
public String getLastName()
{
// return the value of the last name instance variable
return this.lastName;
}

/**
* Update the first name.
*
* @param inFirstName first name of the client.
*/
public void setFirstName(String inFirstName)
{
// Set the first name instance variable to parameter.
// REPLACE this comment with your code
}
  
/**
* Return the first name of the client.
*
* @return String first name.
*/
public String getFirstName;
  

//return "not cor";
  

/**
* Update the age of the client.
*
* @param inAge age of the client.
*/
public void setAge(int inAge)
{
// Set the age instance variable to the parameter
this.age = inAge;
}
  
/**
* Return the age of the client.
*
* @return int first name.
*/
public int getAge()
{
// return the value of the first age instance variable.
return this.age;
}
  
/**
* Update the height of the client.
*
* @param inHeight height of the client.
*/
public void setHeight(int inHeight)
{
// Set the height instance variable to the parameter
this.height = inHeight;
}
  
/**
* Return the height of the client.
*
* @return int height of client.
*/
public int getHeight()
{
// return the value of the height instance variable.
return this.height;
}
  
/**
* Update the weight of the client.
*
* @param inWeight weight of the client.
*/
public void setWeight(int inWeight)
{
// replace this comment with your code
}
  
/**
* Return the weight of the client.
*
* @return int weight of client.
*/
public int getWeight()
{
// replace this comment & return statement with your code
return -1;
}
  
/**
* Calculate the BMI of the client.
*
* @return double BMI of client.
*/
public double calcBMI()
{
// return the result of calculating the BMI.
// Refer to "Common Error 4.1" on page 142 in the textbook for more info
// if WebCat flags the following calculation as an error.
return (704 * this.weight) / this.height * this.height;
}

/**
* Display the client information.
*
* @return String formatted client informatin.
*
* <pre>
* The label should be printed in the format:
*
* last name, first name
* Age: 99
* BMI: 99.999
* </pre>
*/
public String toString()
{
// initialize the variable that will hold the output string
String output = "";
  
// put the name in lastname, firstname format
output = output + this.lastName + this.firstName + "\n";
  
// include the client age
output = output + "Age " + this.age + "\n";
  
// include the email address
output = output + "BMI " + this.calcBMI() + "\n";
  
// return the output string
return output;
}
}

In: Computer Science

Using C++ Design a class named PersonData with the following member variables: lastName firstName address city...

Using C++ Design a class named PersonData with the following member variables:

  1. lastName
  2. firstName
  3. address
  4. city
  5. state
  6. zip
  7. phone

and at a minimum the following member functions:

  1. A class constructor - which initializes all the member variables above
  2. a display() function - which ONLY displays all the person's data to the console
  3. Also write the appropriate accessor/mutator functions for the member variables

Write a NewPersonData function. This is a stand-alone function that you can use in your main to generates a new PersonData object from user input (i.e. internally prompting and retrieving the values necessary to generate a person)

  • prototype - PersonData NewPersonData();
  • how to call - PersonData person = NewPersonData();

In: Computer Science

I need to write this program in Python. Write a program that displays a temperature conversion...

I need to write this program in Python. Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The tabular format of the result should include rows for all temperatures between 70 and 270 degrees Celsius that are multiples of 10 degrees Celsius (check the sample below). Include appropriate headings on your columns. The formula for converting between degrees Celsius and degrees Fahrenheit is as follow F=(9/5C) +32

Celsius Fahrenheit
70 158
80 176
90 194
100 212
.... ...
... ...
270 518

In: Computer Science

PART A - STACKS To complete this assignment: Please study the code posted below. Please rewrite...

PART A - STACKS

To complete this assignment:

Please study the code posted below.

Please rewrite the code implementing a template class using a linked list instead of an array. Note: The functionality should remain the same

***************************************************************************************************************

/**
* Stack implementation using array in C/procedural language.
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
//#include <climits> // For INT_MIN

#define SIZE 100

using namespace std;

/// Create a stack with capacity of 100 elements
int stack[SIZE];

/// Initially stack is empty
int top = -1;


/** Function declaration to perform push and pop on stack */
void push(int element);
int pop();
void display();


int main()
{
int choice, data;

while(1)
{
/* Menu */
cout <<"------------------------------------\n";
cout <<" STACK IMPLEMENTATION PROGRAM \n";
cout <<"------------------------------------\n";
cout <<"1. Push\n";
cout <<"2. Pop\n";
cout <<"3. Size\n";
cout <<"4. Print Stack\n";
cout <<"5. Exit\n";
cout <<"------------------------------------\n";
cout <<"Enter your choice: ";

cin >>choice;

switch(choice)
{
case 1:
cout <<"Enter data to push into stack: ";
cin >> data;

// Push element to stack
push(data);
break;

case 2:
data = pop();

/// If stack is not empty
if (data != INT_MIN)
cout <<"Data => " << data << endl;
break;

case 3:
cout <<"Stack size: " << top + 1 << endl;
break;
case 4:
display();
break;


case 5:
cout <<"Exiting from app.\n";
exit(0);
break;

default:
cout <<"Invalid choice, please try again.\n";
}

cout <<"\n\n";
}


return 0;
}

/**
* Function to push a new element in stack.
*/
void push(int element)
{
/// Check stack overflow
if (top >= SIZE)
{
cout <<"Stack Overflow, can't add more element element to stack.\n";
return;
}

/// Increase element count in stack
top++;

/// Push element in stack
stack[top] = element;

cout <<"Data pushed to stack.\n";
}


/**
* Function to pop element from top of stack.
*/
int pop()
{
/// Check stack underflow
if (top < 0)
{
cout <<"Stack is empty.\n";

/// Throw empty stack error/exception
/// Since C does not have concept of exception
/// Hence return minimum integer value as error value
/// Later in code check if return value is INT_MIN, then
/// stack is empty
return INT_MIN;
}


/// Return stack top and decrease element count in stack
return stack[top--];
}
void display()
{
if ( top >=0)
{
for(int i = 0; i <= top ; i++ )
cout << stack[i] << " ";
cout << endl;
}

else
cout << "stack is empty\n\n";
}

****************************************************

PART B - QUEUES

Please study the code posted below.

Please rewrite the code implementing a template class using a linked list instead of an array. Note: The functionality should remain the same

/**
* Queue implementation using linked list C style implementation ( no OOP).
*/

#include <cstdio>
#include <cstdlib>
#include <climits>
#include <iostream>


#define CAPACITY 100 // Queue max capacity

using namespace std;
/** Queue structure definition */
struct QueueType
{
int data;
struct QueueType * next;
};
/** Queue size */
unsigned int size = 0;


int enqueue(QueueType * &rear, QueueType * &front, int data);
int dequeue(QueueType * &front);
int getRear(QueueType * &rear);
int getFront(QueueType * &front);
void display(QueueType * front);
int isEmpty();
int isFull();
string prepMenu();


int main()
{
int option, data;

QueueType *rear, *front;

rear = NULL;
front = NULL;
string menu = prepMenu();
cout << menu << endl;
cin >> option;
while (option !=7)
{

switch (option)
{
case 1:
cout << "\nEnter data to enqueue (-99 to stop): ";
cin >> data;
while ( data != -99)
{
/// Enqueue function returns 1 on success
/// otherwise 0
if (enqueue(rear, front, data))
cout << "Element added to queue.";
else
cout << "Queue is full." << endl;
cout << "\nEnter data to enqueue (-99 to stop): ";
cin >> data;
}


break;

case 2:
data = dequeue(front);

/// on success dequeue returns element removed
/// otherwise returns INT_MIN
if (data == INT_MIN)
cout << "Queue is empty."<< endl;
else
cout << "Data => " << data << endl;

break;

case 3:

/// isEmpty() function returns 1 if queue is emtpy
/// otherwise returns 0
if (isEmpty())
cout << "Queue is empty."<< endl;
else
cout << "Queue size => "<< size << endl;

break;

case 4:
data = getRear(rear);

if (data == INT_MIN)
cout << "Queue is empty." << endl;
else
cout << "Rear => " << data << endl;

break;

case 5:

data = getFront(front);

if (data == INT_MIN)
cout <<"Queue is empty."<< endl;
else
cout <<"Front => " << data << endl;

break;

case 6:
display(front);
break;

default:
cout <<"Invalid choice, please input number between (0-5).\n";
break;
}

cout <<"\n\n";
cout << menu<< endl;
cin >> option;
}
}

/**
* Enqueues/Insert an element at the rear of a queue.
* Function returns 1 on success otherwise returns 0.
*/
int enqueue(QueueType * &rear, QueueType * &front, int data)
{
QueueType * newNode = NULL;

/// Check queue out of capacity error
if (isFull())
{
return 0;
}

/// Create a new node of queue type
newNode = new QueueType;

/// Assign data to new node
newNode->data = data;

/// Initially new node does not point anything
newNode->next = NULL;

/// Link new node with existing last node
if ( (rear) )
{
rear->next = newNode;
}


/// Make sure newly created node is at rear
rear = newNode;

/// Link first node to front if its NULL
if ( !( front) )
{
front = rear;
}

/// Increment quque size
size++;

return 1;
}


/**
* Dequeues/Removes an element from front of the queue.
* It returns the element on success otherwise returns
* INT_MIN as error code.
*/
int dequeue(QueueType * &front)
{
QueueType *toDequque = NULL;
int data = INT_MIN;

// Queue empty error
if (isEmpty())
{
return INT_MIN;
}

/// Get element and data to dequeue
toDequque = front;
data = toDequque->data;

/// Move front ahead
front = (front)->next;

/// Decrement size
size--;

/// Clear dequeued element from memory
free(toDequque);

return data;
}


/**
* Gets, element at rear of the queue. It returns the element
* at rear of the queue on success otherwise return INT_MIN as
* error code.
*/
int getRear(QueueType * & rear)
{
// Return INT_MIN if queue is empty otherwise rear.
return (isEmpty())
? INT_MIN
: rear->data;
}


/**
* Gets, element at front of the queue. It returns the element
* at front of the queue on success otherwise return INT_MIN as
* error code.
*/
int getFront(QueueType * &front)
{
// Return INT_MIN if queue is empty otherwise front.
return (isEmpty())
? INT_MIN
: front->data;
}


/**
* Checks, if queue is empty or not.
*/
int isEmpty()
{
return (size <= 0);
}


/**
* Checks, if queue is within the maximum queue capacity.
*/
int isFull()
{
return (size > CAPACITY);
}
string prepMenu()
{

string menu = "";

menu+= " \n-------------------------------------------------------------------\n";
menu+= "1.Enqueue 2.Dequeue 3.Size 4.Get Rear 5.Get Front 6.Display 7.Exit\n";
menu+= "----------------------------------------------------------------------\n";
menu+= "Select an option: ";
return menu;
}
void display(QueueType * front)
{
for ( QueueType *t = front; t !=NULL; t = t->next)
cout <<t->data << " ";
cout << endl << endl;
}

In: Computer Science

Write the pseudocodes for these programs: a) #include <iostream> using namespace std; void print(int arr[],int n){...

Write the pseudocodes for these programs:

a)

#include <iostream>

using namespace std;
void print(int arr[],int n){

if(n==0)
return;

cout<<arr[n-1]<<" ";
print(arr,n-1);
}

int main()
{

int n;
cout<<"Enter the size of the array:";
cin>>n;

int arr[n];
int i;
cout<<"Enter the elements of the array:"<<endl;

for(i=0;i<n;i++){
cin >> arr[i];
}

cout<<"Displaying the elements of the array in reverse order:"<<endl;
print(arr,n);
return 0;
}

b)

#include<iostream>
#include<fstream>

using namespace std;
//student structure
struct student
{
int id;
float gpa;
};
//node structure
struct node
{
student *data;
node *link;
};
//linklist class
class List
{
private:
node *head;
public:
List()
{
head=NULL;
}
//function to insert data into List
void Insert(student *S)
{
node *ptr=head;
node *temp=new node();
temp->data=S;
temp->link=NULL;
if(ptr==NULL)
{
head=temp;
}
else
{
while(ptr->link!=NULL)
{
ptr=ptr->link;
}
ptr->link=temp;
}
}
//function to display data
void display()
{
node *ptr=head;
if(ptr==NULL)
{
cout<<"NO DATA EXISTS"<<endl;
}
else
{
while(ptr!=NULL)
{
student *s=ptr->data;
cout<<s->id<<" "<<s->gpa<<endl;
ptr=ptr->link;
}
}
}
};
int main()
{
ifstream infile;
string filename;
List L;
int id;
float gpa;
cout<<"Enter Filename : ";
cin>>filename;
infile.open(filename.c_str());
if(!infile)
{
cout<<"Unable to open file"<<endl;
return 0;
}
while(infile>>id>>gpa)
{
student *ptr=new student();
ptr->id=id;
ptr->gpa=gpa;
L.Insert(ptr);
}
//displaying data to Console
cout<<"STUDENT DATA"<<endl;
L.display();
}

In: Computer Science