ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 4 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 08 May 2017 My Price 11.00

ICT209 Assignment 2, Murdoch University 2016 ICT209

Hello, I need someone whos good at c++ programming(preferably Microsoft Visual C++). Need a templated binary search tree to do the searching of each nodes have two header file and one cpp file). Kindly read the assignment question below. This assignment is continuation of my other assignment here (doxygen comment programs) that will help :) 

 

 

ICT209 Assignment 2, Murdoch University 2016 ICT209 Assignment 2 2016
Objectives:
• Demonstrate that you can do Object Oriented design.
• Demonstrate that you can write Object Oriented programs using C++.
• Demonstrate that you can design and write programs using user defined data
structures.
• Demonstrate that you can use data structures appropriately.
• Demonstrate that you can write test plans and show evidence of systematic testing.
• Demonstrate that you can draw UML diagrams.
• Acquire further experience with design and code maintenance.
You do not work in groups for this assignment as this is an individual assignment.
Worth:
30% of the unit
Due:
Midnight, end of Session 12 (last teaching week). See due date and time (and any
amendments to these) in LMS. The due date and time depends on when is the last day of
the last teaching week for the semester or trimester at the campus you are enrolled in.
How to submit:
Same way as assignment 1. The submission must contain the entire directory/folder in
which the source was built. Other submission items are specified in this document.
Non-Murdoch Campus:
Into the assignment submission area for the unit in LMS.
Murdoch Campus Internal students:
Into the assignment submission area for the unit in LMS.
Externals:
Into the assignment submission area for the unit in LMS.
For submitting in LMS, zip up the entire folder. Make sure that you have included all
needed files. Do not include temporary files or files not relevant to the assignment.
After submitting the assignment, log out of LMS. Then log back in again. Check that the
assignment is submitted.
Name the zip file with the unit code, Assignment number, your name, student number.
ICT209Asg2JoBlogs12345678.zip
or alternatively, ICT209 Assignment 2, Murdoch University 2016 1 ICT209 Assignment 2, Murdoch University 2016 ICT209_Asg2_JoBlogs_12345678.zip
Textual submissions should be type-written. External documentation can only be in the
following formats:
Text (.txt)
PDF (.pdf)
RTF (.rtf)
HTML (.html)
Image formats : PNG, GIF, JPG, TIFF, BMP. (BMP and TIFF cannot be used for Web
documents)
Assignment cover sheet requirements are listed in the unit outline found in the Admin
area. Also see the end of this document.
Mandatory Readings/work needed:
• Unit textbook. “C++ Programming: Program Design Including Data Structures”
by D.S. Malik.
• Lecture notes.
• Complete lab exercises.
o You need to complete all exercises up to laboratory session 10 to cover the
data structures requirements of this assignment.
o Complete laboratory session 11 before submission of this assignment.
• Question and Answer files (QandA) if these exist in the assignment 1 and
assignment 2 area. This QandA file for assignment 2 can be updated on the day of
the assignment submission if someone asks a question on that day and the
question and answer is deemed suitable for sharing with everyone.
• C++ Coding Standards http://0lib.myilibrary.com.prospero.murdoch.edu.au/Open.aspx?id=291948
Assignment Question:
Design an object-oriented solution and implement the solution in C++ to solve the
problem described below. You must read the entire specification and work out what is
needed before starting work on this assignment.
Like assignment 1, this assignment is not for actually buying and selling of shares. The
assignment only deals with data from past share transactions (trades).
You need to read the whole assignment specification first. The solution needs to be
worked out on paper before you start coding.
Extend assignment 1 to do the tasks described below. You need to also reflect on the design and code
changes needed to convert your assignment 1 into assignment 2.
Start early. Design the menu system and test to make sure the menu works. Use code stubs (refer to
your earlier units) to test the overall flow of execution. If you have forgotten what a stub is, see
ICT209 Assignment 2, Murdoch University 2016 2 ICT209 Assignment 2, Murdoch University 2016 http://en.wikipedia.org/wiki/Method_stub for a quick overview. You already have data file reading
code, so make sure that you are able to read data files correctly. In the initial stages, read the files and
print them out to check. Once this stage is completed, you start using the data structures after first unit
testing the data structures.
Create your own test data files as given in these specifications below. You will be submitting these
files.
Make sure you design a simple menu so that users do not get confused or annoyed – consider what it is
like if you were the end-user.
Your program should be able to deal with course of sales data for multiple days and multiple stock
exchange codes (x-code). Each day’s trading data for each stock code (x-code) is still stored in CSV
files. This means that there will be a number of data files for each stock code. For proper testing (for
the various test conditions), you need to create your own data files. These test data files shouldn’t be
large. There should only be enough data to check the test conditions. This involves various x-code
values and dates. You decide on these values and the decision is important as the data values are used
to test your solution.
Program input:
The data format in each course of sales file is the same as assignment 1. As there are multiple x-codes,
the date files are arranged in directories or folders. The folder names are the x-codes. To illustrate,
assume there are course of sales data for 3 companies with their own x-codes. Assume the x-codes are
IAG, NAB, CBA. The data folder will have 3 folders called “IAG”, “NAB”, and “CBA”. This data
folder will have an index file called code_index.txt. The contents of this index file would just be the xcode names whose folder exists in the data folder. The folder names match the x-code names.
So, for this example, code_index.txt will contain each x-code on a line:
IAG
NAB
CBA
The contents of code_index.txt indicate that there are these 3 sub-folders in the data folder.
Do not make any assumption that the x-code is sorted in code_index.txt.
The course of sales files (in CSV format, as in assignment 1) for each day and given x-code will found
in the sub-folder of the data folder. As indicated earlier, the sub-folder is named by the x-code. Do not
make any assumptions about the naming conventions used for the course of sales files. The names of
the files in the x-code sub-folders are listed in a file called sales_index.txt. Each x-code subfolder will
have a sales_index.txt file.
Assuming that the folder IAG has course of sales files day1.csv, day2.csv, day3.csv, the sales_index.txt
file in folder IAG will contain the following lines.
day1.csv
day2.csv
day3.csv.
Do not assume that there is any sort order in sales_index.txt. The names of the CSV files do not
indicate any chronological order. Arrange your data files to reflect this – change the order in which the
files are listed and check. ICT209 Assignment 2, Murdoch University 2016 3 ICT209 Assignment 2, Murdoch University 2016 So to read course of sales data into your program:
In the data folder, read the code_index.txt file.
For each code in code_index.txt
Read code/sales_index.txt
For each csv file in code/sales_index.txt
Load the csv file data into your program.
Endfor
Endfor
The program reads all files and loads the appropriate data structures before the menu is displayed to the
end user.
Program output:
The program reads data from the data files and produces output according to the menu option selected
by the user. As alerted in assignment 1, assignment 2 deals with multiple stock codes and course of
sales for multiple days. Consequently, most of the menu options are variations of what was needed for
assignment 1.
Date is shown as dd/mm/yyyy. (02/01/2014).
Time uses the 24-hour format.
The stock code is the x-code.
Read the requirements for each option, and design your menu system to be user friendly. Your design
may have some of the menu options listed below as sub-menus.
Before any menu option is displayed, the program reads all data files and loads the appropriate data
structures.
Menu option 1:
The highest share price and start time(s) of the highest share price during the day for a user specified
stock code and date. This is printed on the screen in the following format: Stock code: <the stock code>
Date: <the transaction date>
Highest price: <the highest price>
Start time(s):
<time when highest price transaction occurred>
<time when highest price transaction occurred>
...
The highest price could be reached more than once during the day. If so, list each time on a new row.
Do not list duplicate time values.
Menu option 2:
The lowest share price and start time(s) of the lowest share price during the day for a user specified
stock code and date. This is printed on the screen in the following format:
ICT209 Assignment 2, Murdoch University 2016 4 ICT209 Assignment 2, Murdoch University 2016 Stock code: <the stock code>
Date: <the transaction date>
Lowest price: <the lowest price>
Start time(s):
<time when lowest price transaction occurred>
<time when lowest price transaction occurred>
...
The lowest price could be reached more than once during the day. If so, list each time on a new row.
Do not list duplicate time values.
A value of 0 for price should not be part of the output.
Menu option 3:
This option is for a user specified stock code and date.
The output goes to a file called price-change-date.csv where the fields (individual items of data) are
separated by commas. The date part of the file name depends on the user specified date. The format is
yyyy-mm-dd. As an example, an output file can be price-change-2014-02-10.csv. This is the output for
the 10th of February 2014. This file is created in the specified x-code directory.
The output format is:
Stock code, Date, Start time, Price of share, Volume of shares traded, Total value of shares traded Make sure you write the header row. This is the first row of the output file. This involves simply
printing the format line above as a string.
The data file will have a record (row) for each time the share price changes. The output will have data
arranged in increasing time order.
The output fields have the following meanings:
• Stock code: The x-code. • Date: Date of trading. • Start time: The time when the share price changed to the value indicated in the "Price of share"
field. This time value is used to indicate that the share price changed to a new price value. The
input data file may have multiple consecutive records (rows) where the share price is the same.
This means that there may be multiple consecutive share transactions where the share price
remained the same. In the output data file, output.csv, the Start time field records when the
share price changed to a different value. The intention here is that this field records the time of
initial change to a price in a series of consecutive same price transactions. • Volume of shares traded: The number of shares traded since "Start time" at the value indicated
in the "Price of share" field. • Total value of shares traded: The total monetary (dollar) value of the shares given in the
"Volume of shares" field. ICT209 Assignment 2, Murdoch University 2016 5 ICT209 Assignment 2, Murdoch University 2016 Treat a value of zero (0) for the price field in the input data file the same way as other prices are treated.
Menu option 4:
This menu option is to be completed only when all other menu options are working as expected.
Proper completion of this option will give you a 15 marks bonus. If you attempt this option when
any of the other options are not working, no bonus marks would be awarded.
It is theoretically possible to get 115 marks if all options are done perfectly. However the maximum
mark that will awarded is 100.
Calculate a simple moving average (SMA) for the price of a user specified stock code on a given date.
The moving average is over 5 transactions by default. The output goes to a file named SMA-date.csv.
The date part of the file name depends on the user specified date. The format is yyyy-mm-dd. As an
example, an output file can be SMA-2014-02-10.csv. This is the SMA for the 10th of February 2014.
This file is created in the specified x-code directory.
The output format is:
Stock code, Date, Time, Price of share, simple moving average. Make sure you write the header row. This is the first row of the output file. This involves simply
printing the format line above as a string.
Stock code and Date have the same meaning as in option 3. Time is the recorded time in the course of
sales file. Price of share is the price recorded in the course of sales file. The SMA is described at
http://www.investopedia.com/terms/m/movingaverage.asp. Use the approach described at this site but
instead of using daily closing prices, the actual transaction price at a given time recorded in the course
of sales file is used.
Provide a sub-menu of this menu that enables the default of 5 transactions for the moving average to be
changed to some other value.
Price values of 0 must not be averaged.
Menu option 5:
Exit the program Data Structures requirement:
STL data structures and algorithms can be used in this assignment. You must use the Binary search
tree data structure and the STL map (and/or multimap) data structure.
The data for the output in the various menu options must come from these data structures. You may use
other data structures together with the STL map and tree.
You need to identify where these data structures can be used and provide a rationale for their use.
There is a 30 marks penalty if you do not do this.
You may use std::string and string stream classes in your program instead of using C like strings. You
may use iostream and file handling classes and objects in C++. See laboratory exercises.
ICT209 Assignment 2, Murdoch University 2016 6 ICT209 Assignment 2, Murdoch University 2016 When working on this assignment, think of the usability of your program from the point of view
of the user. This is the first thing you have to do, even before you start designing the program.
This will form the menu system for the running program. You should not make the program
more complicated than what is specified in the assignment. Make sure you provide an option to
exit the program. It is not a good idea to exit a program by killing the program or by re-booting
the computer.
Any advice and further clarifications to these requirements would be found in the QandA file in the
assignment 2 area. Please ask your questions early and do not wait till near the due date as you may not
have time to incorporate any answers into your assignment. Documentation: (Printed versions apply only when there is a notification in LMS
asking for hard copies. Ignore the advice below for printed copies if there is no
notification in LMS)
• UML diagram showing the design of your classes. (printed and soft copy)
• Reflection on the changes you had to make to cater for the requirements of
assignment 2. You describe what parts of your assignment 1 design and code
enabled you to complete the requirements of assignment 2 easily. What parts of
your assignment 1 design and code were a problem? (printed and softcopy)
• Rationale for the use of the data structures in the program. (printed and softcopy)
• A high level algorithm for the solution. (printed and softcopy)
• Doxygen output which shows all information as was done in the practice for
session 2. (soft copy only)
• Test plan and output of the test run(s). (soft copy only)
Do not print code. Code will only exist as soft copy. You need to submit the entire
directory/folder where you built your program. All relevant data files need to be there
and a way must be provided to build with either Microsoft Visual Studio or Code:Blocks
on a Windows operating system.
Minimum requirements:
You must provide all of the following; otherwise 50 marks will be deducted.
• UML diagram
• Reflection on the design and code conversion from assignment 1 to assignment 2.
• Written rationale for the data structures: tree, map/multimap and any others used.
• Doxygen output
• Program that builds (using Microsoft Visual C++ or code::blocks) and runs.
Build mechanism must be provided.
• Source code. Doxygen style comments in header files. (soft copy only)
• Test plan and output of test run(s)
• Executable program with associated data files in a separate directory called
“executable”. Make sure that the executable runs on a machine which does not
have a compiler. Data files needed to enable it run should be included here.
ICT209 Assignment 2, Murdoch University 2016 7 ICT209 Assignment 2, Murdoch University 2016 • A declaration indicating what works and what does not work in your program.
This can form the summary of your test plan and output of test runs and should be
provided as a separate document called “evaluation.txt”. This is an unformatted
text file and it is not the test plan or output of test runs.
Marking
UML diagram
Design reflection and rationale for data structures
Program (includes coding style and comments)
Test plan and testing 10%
20%
55 % + 15% bonus for menu 4
15% There is a 10 marks penalty if the cover sheet is not filled in properly and/or the
requirements of the coversheet are not met. If the cover sheet is not provided, you get no
marks. There is a separate cover sheet available.
If progress on this assignment is not demonstrated to your tutor in the weeks
prior to the submission of the assignment, you may not get any marks for this
assignment. We need to know that you have been working on the assignment.
The assignment must not “magically” appear. Please check the unit guide for
the requirements for passing the unit – section on “Determination of the final
grade”.
Penalty summary:
Specified data structures not used: -30 marks
Missing minimum requirements: -50 marks
Cover sheet problems: -10 marks (cover sheet is not required now for LMS submissions, but you
should ensure that all requirements are met for the cover sheet and submission into LMS.) The lowest total mark you can get is 0. ICT209 Assignment 2, Murdoch University 2016 8 ICT209 Assignment 2, Murdoch University 2016 School of Engineering and Information Technology
ICT209 COVER SHEET used for Non-LMS submission
Given Names Surname Student Numbers Name of tutor: _____________________________
Assignment Number: __2___ Mode (D/X) Email Day & Time of tutorial: _________________ Due Date: ______________ Date Submitted: ______________ If the given name by which your tutor knows you differs from your name on university records, you should indicate both names
above. Tutor’s name must be entered. Penalty is 10% of the total marks for the submission for not providing information asked for.
Your assignment should meet the following requirements. Please confirm this (by ticking boxes) before submitting your assignment
that you have checked the declarations you need to make. Some items do not apply for online/electronic submission. Except where I have indicated, the work I am submitting is my own work for the purpose of this assessment and has not been
submitted for assessment in another unit.
This submission complies with Murdoch University's academic integrity commitments. I am aware that information about
plagiarism and associated penalties can be found at http://www.murdoch.edu.au/teach/plagiarism/. If I have any doubts or
queries about this, I am further aware that I can contact my Unit Coordinator prior to submitting the assignment.
I acknowledge and agree that the assessor of this assignment may, for the purpose of assessing this assignment:
• Reproduce this assignment and provide a copy to another academic staff member; and/or
• Submit a copy of this assignment to a plagiarism-checking service. This web-based service will retain a copy of this work
for the sole purpose of subsequent plagiarism checking, but has a legal agreement with the University that it will not
share or reproduce it in any form.
I have retained a copy of all submitted work.
I will retain a copy of the notification of receipt of this assignment. LMS submission would provide the required receipt. If
you have not received a receipt within three days, please check with your Unit Coordinator.
Assignment is presented on A4 size paper and is neatly collated. (Internal students)
Assignment includes virus-free disk with machine-readable programs & files relevant only to this submission. CD or DVD
only may be accepted. (Internal students)
Instructions relating to answering of questions, formats used for electronic submission and LMS submission have been
followed.
Writing is clearly legible or has been printed.
Pages have been firmly stapled. (Internal students) ____________________________
Signature for submission via the assignment box (internal students) ICT209 Assignment 2, Murdoch University 2016 9

 

Doxygen Comment Programs
DATE
Header file: #pragma
#ifndef H_DateT
#define H_DateT
#include <iostream>
#include <string>
using namespace std;
class DateT
{
friend ostream& operator << (ostream&, const DateT&);
friend istream& operator >> (istream&, DateT&);
public: /**
*@brief default constructor
* Initializing the date object with default value
*/
DateT();
/**
*@brief specific constructor
* Initializing the date object with specific value
*@param string d, string m, string y - day, month, year
*/
DateT(string d,string m,string y);
///setters
/**
*@brief setting the day of date
*@param day = d
*@return void
*/
void setDay(string d);
/**
*@brief setting the month of date
*@param month = m
*@return void
*/
void setMonth(string m);
/**
*@brief setting the year of date
*@param year = y
*@return void
*/
void setYear(string y);
/**
*@brief setting all the values of date *@param day = d , month = m and year = y
*@return void
*/
void setDate(string d,string m,string y);
//getters
/**
*@brief returning the day value of date
*@return string
*/
string getDay() const;
/**
*@brief returning the month value of date
*@return string
*/
string getMonth() const;
/**
*@brief returning the year value of date
*@return string
*/
string getYear() const;
/**
*Will print the details of the date
*@return void
*/
void printDate() const;
private:
///data members
string day;
string month;
string year;
};
#endif ///for the above ifndef Source File: #include <iostream>
#include <string>
#include "DateT.h"
using namespace std;
///Default Constructor
DateT::DateT()
{
day= "04";
month= "17";
year= "1998" ;
}
///Specific Constructor DateT::DateT(string d,string m,string y)
{
day=d;
month=m;
year=y;
}
/*
*Function to set day
*The member variable day is set with d
*Postcondtion day=d;
*/
void DateT::setDay(string d)
{
day=d;
}
/**
*Function to set month
*The member variable month is set with m
*Postcondtion month=m;
*/
void DateT::setMonth(string m)
{
month=m;
}
/**
*Function to set year
*The member variable year is set with y
*Postcondtion year=y;
*/
void DateT::setYear(string y)
{
year=y;
}
/**
*Function to set everything
*/
void DateT::setDate(string d,string m,string y)
{
day=d;
month=m;
year=y;
}
/**
*Function to return the day
*Postcondition : The value of the day is returned
*/
string DateT::getDay() const
{
return day;
}
/**
*Function to return the month
*Postcondition : The value of the month is returned
*/
string DateT::getMonth() const
{
return month;
}
/*
*Function to return the year
*Postcondition : The value of the year is returned */
string DateT::getYear() const
{
return year;
}
/**
*Will print the details of the time
*@return void
*/
void DateT::printDate() const
{
cout<<day<<"/"<<month<<"/"<<year;
}
ostream& operator << (ostream& osObject,const DateT& date1)
{
osObject<<date1.day
<<"/"<<date1.month
<<"/"<<date1.year;
return osObject;
}
istream& operator >>(istream& isObject,DateT& date1)
{
isObject>>date1.day>>date1.month>>date1.year;
return isObject;
} TIME
Header file: #pragma
#ifndef H_TimeT
#define H_TimeT
#include <iostream>
#include <string>
using namespace std;
class TimeT
{
public:
friend ostream& operator << (ostream& , const TimeT&);
friend istream& operator >> (istream& , TimeT&);
/**
*@brief default constructor
* Initializing the time object with default value
*/
TimeT();
/**
*@brief specific constructor
* Initializing the date object with specific value
*@param string d, string m, string y - day, month, year
*/
TimeT(string hr,string min, string sec); ///setters
/**
*@brief setting the hour of time
*@param hour = h
*@return void
*/
void setHour(string hr);
/**
*@brief setting the minute of time
*@param minute = m
*@return void
*/
void setMinute(string min);
/**
*@brief setting the second of time
*@param second = sec
*@return void
*/
void setSecond(string sec);
/**
*@brief setting all the values of time
*@param hour = h, minute = min and second sec
*@return void
*/
void setTime(string hr,string min,string sec);
///getters
/**
*@brief returning the hour value of time
*@return string
*/
string getHour() const;
/**
*@brief returning the minute value of time
*@return string
*/
string getMinute() const;
/**
*@brief returning the second value of time
*@return string
*/
string getSecond() const;
/**
*Will print the details of the time
*@return void
*/
void printTime() const;
private:
///Data members
string hour;///hour of the share traded
string minute;///minute of the share traded
string second; /// second of the share traded
}; #endif ///for the above ifndef Source File:
#include <iostream>
#include <string>
#include "TimeT.h"
using namespace std;
/**
*@brief default constructor
* Initializing the time object with default value
*/
TimeT::TimeT()
{
hour = "0";
minute = "0";
second = "0";
}
/** *@brief default constructor
* Initializing the time object with default value
*/ TimeT::TimeT(string hr,string min, string sec)
{ } hour=hr;
minute=min;
second = sec; /**
*Function to set hr
*The member variable hr is set with hr
*Postcondtion hr=hr;
*/
void TimeT::setHour(string hr)
{
hour=hr;
}
/**
*Function to set min
*The member variable min is set with min
*Postcondtion min=min;
*/
void TimeT::setMinute(string min)
{
minute=min;
}
/**
*Function to set second *The member variable second is set with sec
*Postcondtion second=sec;
*/
void TimeT::setSecond(string sec)
{
second = sec;
}
/**Specific Constructor
*@brief Function to set TimeT details
*The member variables are set according to the parameters.
*@param day=d,month=m;year=y;hr=h;min=min;second=sec;
*/
void TimeT::setTime(string hr,string min,string sec)
{ } hour=hr;
minute=min;
second = sec; /**
*@brief Function to return the hr
*The value of the hr is returned
*/
string TimeT::getHour() const
{
return hour;
}
/**
*@brief Function to return the min
*The value of the min is returned*/
string TimeT::getMinute() const
{
return minute;
}
/**
*@brief Function to return the second
*The value of the second is returned
*/
string TimeT::getSecond() const
{
return second;
}
/**
*@brief Function to print the TimeT details
*/
void TimeT::printTime() const
{
cout << "Time" ,hour,":",minute, ":", second;
}
ostream& operator << (ostream& osObject,const TimeT& time1)
{
osObject << time1.hour << ":" << time1.minute << ":" << time1.second;
return osObject;
}
istream& operator >>(istream& isObject,TimeT& time1) {
isObject >> time1.hour >> time1.minute >> time1.second;
return isObject;
} STOCK
Header file: #pragma
#ifndef H_StockT
#define H_StockT
#include <iostream>
#include <string>
#include "DateT.h"
#include "TimeT.h"
using namespace std;
class StockT
{
friend ostream& operator << (ostream&, const StockT&);
friend istream& operator >> (istream&, StockT&);
public:
/**
*@brief default constructor
* Initializing the stock object with default value
*/
StockT();
/**
*@brief specific constructor
* Initializing the stock object with specific value
*@param double pri, int vol, double val, string d, string m, string y,
*string hr, string min, string sec -price, value, volume, day, month, year, hour,
minute, second
*/
StockT(double pri,int vol,double val,string d,string m,string y,string hr,string min,
string sec);
///setters
/**
*@brief setting the price of stock
*@param price = pri
*@return void
*/
void setPrice(double pri);
/**
*@brief setting the volume of stock
*@param volume = vol
*@return void
*/
void setVolume(int vol);
/**
*@brief setting the value of stock *@param value = val
*@return void
*/
void setValue(double val);
/**
*@brief setting all the values of stock
*@param price = pri, volume = vol, value = val, day = d,
*month = m, year = y, hour = h, minute = min and second sec
*@return void
*/
void setAll(double pri,int vol,double val,string d,string m,string y,string hr,string
min,string sec);
//getters
/**
*@brief returning the price value of stock
*@return string
*/
double getPrice() const;
/**
*@brief returning the volume value of stock
*@return string
*/
int getVolume() const;
/**
*@brief returning the value of stock
*@return string
*/
double getValue()const;
/**
*@brief returning the date value of stock
*@return data type
*/
DateT getDate() const;
/**
*@brief returning the time value of stock
*@return data type
*/
TimeT getTime() const;
/**
*Will print the details of the stock
*@return void
*/
void printStock() const;
private:
///data members
DateT dates; ///date traded
TimeT times; ///time traded
double price; ///price at which the StockT was traded
int volume;///volume of the StockT traded
double value;///dollar of the StockT traded
};
#endif ///for the above ifndef Source file: #include <iostream>
#include <string>
#include "StockT.h"
using namespace std;
/** *@brief default constructor
* Initializing the stock object with default value
*/ StockT::StockT()
{
price=1.0;
volume=0;
value=1.0;
}
/**
*@brief specific constructor
* Initializing the stock object with specific value
*@param double pri, int vol, double val, string d, string m, string y,
*string hr, string min, string sec -price, value, volume, day, month, year, hour,
minute, second
*/
StockT::StockT(double pri,int vol,double val,string d,string m,string y,string hr,string min,
string sec):dates(d,m,y),times(hr,min,sec)
{
price=pri;
volume=vol;
value=val;
}
/**
* @brief Function to set price of the StockT traded
* The member variable price is set with p.
* @param price=p;
*/
void StockT::setPrice(double pri)
{
price=pri;
}
/**
*@brief Function to set volume of the StockT traded
* The member variable volume is set with v.
* @param volume=v;
*/
void StockT::setVolume(int vol)
{
volume=vol;
}
/**
*Function to set value of the StockT traded
* The member variable value is set with v.
* @param price=p;
*/ void StockT::setValue(double val)
{
value=val;
}
/**
* @brief Function to set StockT details
* The member variables are set according to the parameters.
* @param
price=p;volume=v;value=value1;day=d,month=m;year=y;hour=h;minute=min;second=sec;
*/
void StockT::setAll(double pri,int vol,double val,string d,string m,string y,string hr,string
min,string sec)
{
price=pri;
volume=vol;
value=val;
dates.setDate(d,m,y);
times.setTime(hr,min,sec);
}
/**
*@brief Function to return the price
* @param The value of the price is returned
*/
double StockT::getPrice() const
{
return price;
}
/*
*@brief Function to return the volume
*Postcondition : The value of the volume is returned
*/
int StockT::getVolume() const
{
return volume;
}
/**
* @brief Function to return the value
* @param The value of the value is returned
*/
double StockT::getValue() const
{
return value;
}
/**
* @brief Function to return the dates
* @param The value of the dates is returned
*/
DateT StockT::getDate() const
{
return dates;
}
/**
*@brief Function to return the times
* @param The value of the times is returned
*/
TimeT StockT::getTime() const
{
return times;
} /**
*Will print the details of the stock
*@return void
*/
void StockT::printStock() const
{
dates.printDate();
times.printTime();
cout << ", " << price << ", " << volume << ", " << value << endl;
}
/**Function to print the details of the StockT
*/
ostream& operator << (ostream& osObject,const StockT& Stock1)
{
osObject << Stock1.dates << " " << Stock1.times << " " << Stock1.price << " " <<
Stock1.volume << " " << Stock1.value;
return osObject;
}
istream& operator >>(istream& isObject,StockT& Stock1)
{
isObject >> Stock1.dates >> Stock1.times >> Stock1.price >> Stock1.volume >>
Stock1.value;
return isObject;
} VECTOR
Header and Source file: #ifndef H_VectorT
#define H_VectorT
//---------------------------------------------------------------------------#include <iostream>
#include <string>
using namespace std;
template <class elemType>
class VectorT
{
public:
/**
*@brief default constructor
* Initializing the vector with default value
*/
VectorT(); /**
*@brief Store the elements to the array according to the parameter
*@param elemType& i */
void push_back(const elemType& i);
/**
*Will print the details of the vector
*@return void
*/
void print() const;
/**
*To return the arrays
*@return int
*/
int size() const;
/**
*To return the elements to a certain location
*@return int i
*/
elemType at(int i) const;
/**
*To see if the array is empty
*/
bool isEmpty() const;
/**
*To see if the array is full
*/
bool isFull() const; private:
///data members
elemType *list;
int length;
int maxsize;
};
///Implementation
///To check if the vector is empty
template<class elemType>
bool VectorT<elemType>::isEmpty() const
{
return (length == 0);
}
///For printing the vector
template<class elemType>
void VectorT<elemType>::print() const
{
for (int i = 0; i < length; i++)
{
cout << list[i] << " ";
cout << endl;
}
} ///Default Constructor
template<class elemType>
VectorT<elemType>::VectorT()
{
maxsize = 4000;
length = 0;
list = new elemType[maxsize];
}
///Inserting elements into the array
template<class elemType>
void VectorT<elemType>::push_back(const elemType& i)
{
list[length] = i;
length++;
}
///Put array into a certain locatin
template<class elemType>
elemType VectorT<elemType>::at(int i) const
{
if ( i < length)
{
return list[i];
}
}
///Return the size of the vector
template<class elemType>
int VectorT<elemType>::size() const
{
return length;
}
#endif ///for the above ifndef MAINTEST
Source file: #include
#include
#include
#include
#include
#include "StockT.h"
"VectorT.h"
<fstream>
<string>
<iomanip>
<iostream> using namespace std;
///Calling for the void methods
void highestprice(); void lowestprice();
void outfile();
///Calling other class
VectorT<StockT> V1;
StockT S1;
DateT D1;
TimeT T1;
int main()
{
///Inputting variables
int option;
string d1, m1, y1, hr1, min1, sec1, condition;
string dateTime;
double price, value;
int volume;
ifstream infile;
///----------------Reading the Share------------------------------infile.open("courseofsales.txt"); ///Openning the file
if(infile.is_open())
{
infile.ignore(500, '\n');
infile.ignore(500, '\n');
while (getline(infile, dateTime, '\n'))
{
while (!infile.eof())
{
d1 = dateTime.substr(0, 2);
m1 = dateTime.substr(3, 2);
y1 = dateTime.substr(6, 4);
hr1 = dateTime.substr(11, 2);
min1 = dateTime.substr(14, 2);
sec1 = dateTime.substr(17, 2);
infile.ignore(50, '\t'); ///ignoring certain price lines
infile >> price;
infile.ignore(50, '\t'); ///ignoring certain volume lines
infile >> volume;
infile.ignore(50, '\t'); ///ignoring certain value lienes
infile >> value;
getline(infile,condition);
S1.setAll(price, volume, value, d1,m1,y1,hr1, min1, sec1);
V1.push_back(S1);
}
}
infile.close(); ///closing the infile
}
else cout << "Sorry cannot open your file (!!)"; ///----------------------Options------------------do{
cout<< "Please pick a menu options bellow:" << endl;
cout<< "1: Highest price " << endl;
cout<< "2: Lowest price " << endl;
cout<< "3: Output File " << endl;
cout<< "4: Exit " << endl; cout<< "Enter your menu option:";
cin >> option;
cout << endl;
if(option==1)
{ } cout << "This is the highest bid of the day: " << endl;
highestprice(); ///calls the method for retrieving the highest price
cout << endl; else if (option == 2)
{
cout << endl << "This is the lowest bid of the day: " << endl;
lowestprice(); ///calls the method for retrieving lowest price
cout << endl;
} << endl; else if (option == 3)
{
cout << endl << "Kindly check the output file named 'output.csv' (!!) "
} outfile(); ///calls the method to create output.csv else if (option == 4)
exit(0); ///exit the program
else
{
cout << endl << "This is an invalid choice. Enter again. " << endl; //if
the number is invalid
}
}
while(option != 1 || option != 2 || option != 3 || option != 4);
system("PAUSE");
return 0;
}
void highestprice()
{
///Retrieving highest price
double highest = V1.at(0).getPrice();
for (int i = 0; i < V1.size(); i++)
{
if (V1.at(i).getPrice() > highest)
{
highest = V1.at(i).getPrice();
}
}
for (int j = 0; j < V1.size(); j++)
{
if (V1.at(j).getPrice() == highest)
{
cout << "Date and Time of transaction: " <<
V1.at(j).getDate() << V1.at(j).getTime()<< endl;
cout << "Highest price: " << V1.at(j).getPrice() <<
endl;
break; }
}
cout << endl;
}
void lowestprice()
{
///Retrieving lowest price
double lowestprice = V1.at(0).getPrice();
for (int i = 0; i < V1.size(); i++)
{
if ((V1.at(i).getPrice() < lowestprice) && (V1.at(i).getPrice() != 0))
{
lowestprice = V1.at(i).getPrice();
}
}
for (int j = 0; j < V1.size(); j++)
{
if (V1.at(j).getPrice() == lowestprice)
{
cout << "Date and Time of transaction: " << V1.at(j).getDate() <<
V1.at(j).getTime()<< endl;
cout << "Lowest price: " << V1.at(j).getPrice() << endl;
break;
}
}
cout << endl;
}
///-------------------------Creates the output file--------------------------------void outfile()
{
ofstream outfile;
outfile.open("output.csv");
if (outfile.is_open())
{
for (int i = 0; i < V1.size(); i++)
{
outfile << V1.at(i).getDate() << "," << setw(5);
outfile << V1.at(i).getTime() << "," << setw(5);
outfile << V1.at(i).getPrice() << "," << setw(5);
outfile << V1.at(i).getVolume() << "," << setw(5);
outfile << V1.at(i).getValue();
outfile << '\n';
}
outfile.close();
}
else
} cout << "Unable to write file";

Attachments:

Answers

(11)
Status NEW Posted 08 May 2017 08:05 AM My Price 11.00

-----------

Attachments

file 1494230807-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)