Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

INTRODUCTION This project consists of two parts, the second of which appears bel

ID: 3564019 • Letter: I

Question

INTRODUCTION

This project consists of two parts, the second of which appears below. For the first part, write a class that implements an unordered list abstract data type using a doubly-linked list with pointers to both its first and last nodes. The second part of the project specifies a client program that uses the class.

DESCRIPTION

Write a class that implements an unordered list ADT. This class should provide the following operations:

Implement the unordered-list ADT using a doubly-linked list with pointers to both its first and last nodes, as in this figure:

In the class that implements the list ADT as a doubly-linked list, include two data members: a pointer to the first node in the list, and a pointer to the last node in the list. Note that the pointer to the list's last node makes both append() and remove_last() fast. Thus the class's data members will be something like this:

You may want to write a program with which to test this class.

Here's something to do with the unordered-list implementation:

DESCRIPTION

Consider this line-editing problem: A program reads characters one at a time, then prints them back to the terminal in order. However, the character `#' is not to be saved. Rather, it indicates that the program is to delete the most recent character. After reading reaches the end of the line, the surviving characters are printed in forward order. For example:

Write a program that uses the unordered-list implementation to solve the editing problem just described. Use a doubly-linked list, provided by the class, to hold the characters of the input line in the order in which they are entered.

INPUT

The program reads a line of characters, any number of which may be the delete character `#'.

OUTPUT

The program prints the surviving (non-deleted) characters from the input, in the order in which they appeared.

ERRORS

The program may assume that the input is as described; it need not detect any errors.

EXAMPLE

A run of the program might look like this:

and another might look like this:

HINTS

The Item type in the unordered list class is char.

For the client program, recall that the function get() reads the next character from the named input stream into the function's parameter, which is passed by reference. Example:cin.get(ch);

input: abcd##ef => output: abef INTRODUCTION This project consists of two parts, the second of which appears below. For the first part, write a class that implements an unordered list abstract data type using a doubly-linked list with pointers to both its first and last nodes. The second part of the project specifies a client program that uses the class. DESCRIPTION Write a class that implements an unordered list ADT. This class should provide the following operations: A default constructor that initializes a newly declared list to be empty. A destructor that deletes all the nodes in a list. empty(), a boolean function that reports if the list that invokes it is empty. append(entry), which appends the item entry at the end of the list. remove_last(), which removes the last item from the list. An output function that prints the list in forward order to an output stream; you may assume that delete the last character. -> aabbcc#ddee##fg#h aabbcddfh and another might look like this: Enter a line of characters; # => delete the last character. - > djfg#######abc#def abdef HINTS The Item type in the unordered list class is char. For the client program, recall that the function get() reads the next character from the named input stream into the function's parameter, which is passed by reference. Example:cin.get(ch);

Explanation / Answer

The pseudocode for the Annual Return of Stock market is as shown below:

//create a class for StockMarket

Begin StockMarket class:

     //create variables market and investmentfallsrange

     Declare:

String market;

          int investment_falls_range;

   

     //create constructor

     Constructor:StockMarket(String m, int i)

          market=m;

          investment_falls_range=i;

     EndOf Constructor

   

     // setter and getter methods to access the instance

// variables

     setMarket(String mark)

               market=mark;

     Endof setMarket

     setinvestment(int invest)

               investment_falls_range=invest;

     Endof setMarket

   

     String getMarket()

               return market;

     Endof getMarket

     int getinvestment()

               return investment_falls_range;

     Endof getinvestment

EndOf StockMarket

Begin StockMarketTable class:

     Declare and initialize:

          String[] market={"bear ", "stagnant", "bull", "boom"};

          int[] investment_falls={10, 30, 43, 17};

          StockMarket[] sm=new StockMarket[4];

     Constructor:StockMarketTable()

        

               for(int i=0;i<4;i++)

               {

                   sm[i]=new StockMarket(market[i],

investment_falls[i]);

               }

        

     EndOf Constructor

   

     displayMarketInvestments(int range)

          if(range < -10) Then

                    System.out.println("The rate of return is"+

" indicative of a "+sm[0].getMarket()+

                   " market (which occurs "

+sm[0].getinvestment()+"% of the time). ");

          Endif

          else if(range >= -10 && range <10) Then

                    System.out.println("The rate of return is"+

"indicative of a "+sm[1].getMarket()+

                   " market (which occurs "

+sm[1].getinvestment()+"% of the time). ");

        

          EndElseif

          else if(range >= 10 && range <30) Then

                    System.out.println("The rate of return is"+

"indicative of a "+sm[2].getMarket()+

                   " market (which occurs "

+sm[2].getinvestment()+"% of the time). ");

          EndElseif

          else if(range >=30) Then

                    System.out.println("The rate of return is"+

"indicative of a "+sm[3].getMarket()+

                   " market (which occurs "

+sm[3].getinvestment()+"% of the time). ");

          EndElseif

     EndOf displayMarketInvestments

EndOf StockMarketTable

//implementation class

import java.util.*;

Begin StockMarketImpementation class:

     main()

     {

          int rate;

          //create object

          StockMarketTable smt=new StockMarketTable();

          System.out.println("Enter rate of return: ");

          //read input

read rate = nextInt();

//call displayMarketInvestments method

          call displayMarketInvestments(rate);

     }

Endof StockMarketImpementation

------------------------------------------------------------------------------------------------------------------

Sample Output:

Enter rate of return:

15

The rate of return is indicative of a bull market (which occurs 43% of the time).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote