Question: IN C + + , 1 5 . 2 7 LAB: Mileage tracker for a runner Given the MileageTrackerNode class containing the number of miles
IN C LAB: Mileage tracker for a runner
Given the MileageTrackerNode class containing the number of miles a runner runs on a certain date, complete main to perform the following tasks:
Read the number of nodes in the linked list from user input, followed by the number of miles and date of each node.
Use the MileageTrackerNode's InsertAfter function to insert each node according to the input sequence ie insert each node after the last node
Print the entire linked list using the MileageTrackerNode's PrintNodeData function. DO NOT print the head node that does not contain userinput values. Hint: PrintNodeData only outputs values in one node; therefore, iterate through the linked list.
Ex If the input is:
the output is:
Here is the main cpp file #include "MileageTrackerNode.h
#include "MileageTrackerNode.h
#include
#include
using namespace std;
int main
References for MileageTrackerNode objects
MileageTrackerNode headNode;
MileageTrackerNode currNode;
MileageTrackerNode lastNode;
double miles;
string date;
int i;
Front of nodes list
headNode new MileageTrackerNode;
End of nodes list
lastNode headNode;
TODO: Read in the number of nodes
TODO: For the input number of nodes, read the number of miles and date
from user input. Insert each node into the end of the linked list after the last node
TODO: Print the entire linked list with PrintNodeData function calls
MileageTrackerNode Destructor deletes all following nodes
delete headNode;
return ;
Here is MileageTrackerNode.h File is marked as read only
#ifndef MILEAGETRACKERNODEH
#define MILEAGETRACKERNODEH
#include
using namespace std;
class MileageTrackerNode
public:
Constructor
MileageTrackerNode;
Destructor
~MileageTrackerNode;
Constructor
MileageTrackerNodedouble milesInit, string dateInit;
Constructor
MileageTrackerNodedouble milesInit, string dateInit, MileageTrackerNode nextLoc;
Insert node after this node.
Before: this next
After: this node next
void InsertAfterMileageTrackerNode nodeLoc;
Get location pointed by nextNodeRef
MileageTrackerNode GetNext;
void PrintNodeData;
private:
double miles; Node data
string date; Node data
MileageTrackerNode nextNodeRef; Reference to the next node
;
#endif
Here is MileageTrackerNode.cpp File is marked as read only
#include "MileageTrackerNode.h
#include
Constructor
MileageTrackerNode::MileageTrackerNode
miles ;
date ;
nextNodeRef nullptr;
Destructor
MileageTrackerNode::~MileageTrackerNode
ifnextNodeRef nullptr
delete nextNodeRef;
Constructor
MileageTrackerNode::MileageTrackerNodedouble milesInit, string dateInit
miles milesInit;
date dateInit;
nextNodeRef nullptr;
Constructor
MileageTrackerNode::MileageTrackerNodedouble milesInit, string dateInit, MileageTrackerNode nextLoc
miles milesInit;
date dateInit;
nextNodeRef nextLoc;
Insert node after this node.
Before: this next
After: this node next
void MileageTrackerNode::InsertAfterMileageTrackerNode nodeLoc
MileageTrackerNode tmpNext;
tmpNext nextNodeRef;
nextNodeRef nodeLoc;
nodeLocnextNodeRef tmpNext;
Get location pointed by nextNodeRef
MileageTrackerNode MileageTrackerNode::GetNext
return nextNodeRef;
void MileageTrackerNode::PrintNodeData
cout miles date endl;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
