Please use the code at the bottom and add what is needed, also please remove the extra zeros just like the output exampl

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Please use the code at the bottom and add what is needed, also please remove the extra zeros just like the output exampl

Post by answerhappygod »

Please use the code at the bottom and add what is needed, alsoplease remove the extra zeros just like the output example show,thank you.
Please Use The Code At The Bottom And Add What Is Needed Also Please Remove The Extra Zeros Just Like The Output Exampl 1
Please Use The Code At The Bottom And Add What Is Needed Also Please Remove The Extra Zeros Just Like The Output Exampl 1 (30.59 KiB) Viewed 46 times
main.cpp
#include "MileageTrackerNode.h"#include <string>#include <iostream>using namespace std;int main (int argc, char* argv[]) {// References for MileageTrackerNode objectsMileageTrackerNode* headNode;MileageTrackerNode* currNode;MileageTrackerNode* lastNode;double miles;string date;int i;// Front of nodes listheadNode = new MileageTrackerNode();lastNode = headNode;// TODO: Read in the number of nodes// TODO: For the read in number of nodes, read// in data and insert into the linked list// TODO: Call the PrintNodeData() method// to print the entire linked list// MileageTrackerNode Destructor deletes all// following nodesdelete headNode;}
MileageTrackerNode.h
#ifndef MILEAGETRACKERNODEH#define MILEAGETRACKERNODEH
#include <string>using namespace std;
class MileageTrackerNode { public: // Constructor MileageTrackerNode();
// Destructor ~MileageTrackerNode();
// Constructor MileageTrackerNode(double milesInit, stringdateInit);
// Constructor MileageTrackerNode(double milesInit, stringdateInit, MileageTrackerNode* nextLoc);
/* Insert node after this node. Before: this -- next After: this -- node -- next */ void InsertAfter(MileageTrackerNode*nodeLoc);
// Get location pointed bynextNodeRef MileageTrackerNode* GetNext();
void PrintNodeData(); private: double miles; //Node data string date; // Node data MileageTrackerNode* nextNodeRef; // Referenceto the next node};
#endif
MileageTrackerNode.cpp
#include "MileageTrackerNode.h"#include <iostream>
// ConstructorMileageTrackerNode::MileageTrackerNode() { miles = 0.0; date = ""; nextNodeRef = nullptr;}
// DestructorMileageTrackerNode::~MileageTrackerNode() { if(nextNodeRef != nullptr) { delete nextNodeRef; }}
// ConstructorMileageTrackerNode::MileageTrackerNode(double milesInit, stringdateInit) { miles = milesInit; date = dateInit; nextNodeRef = nullptr;}
// ConstructorMileageTrackerNode::MileageTrackerNode(double milesInit, stringdateInit, MileageTrackerNode* nextLoc) { miles = milesInit; date = dateInit; nextNodeRef = nextLoc;}
/* Insert node after this node.Before: this -- nextAfter: this -- node -- next*/void MileageTrackerNode::InsertAfter(MileageTrackerNode* nodeLoc){ MileageTrackerNode* tmpNext;
tmpNext = nextNodeRef; nextNodeRef = nodeLoc; nodeLoc->nextNodeRef = tmpNext;}
// Get location pointed by nextNodeRefMileageTrackerNode* MileageTrackerNode::GetNext() { return nextNodeRef;}
void MileageTrackerNode::PrintNodeData(){ cout << miles << ", " << date<< endl;}
Given the MileageTracker Node class, complete main() to insert nodes into a linked list (using the InsertAfter() function). The first user-input value is the number of nodes in the linked list. Use the PrintNodeData() function to print the entire linked list. DO NOT print the dummy head node. Ex. If the input is: 3 2.2 7/2/18 3.2 7/7/18 4.5 7/16/18 the output is: 2.2, 7/2/18 3.2, 7/7/18 4.5, 7/16/18 409936 2494510x3mv7
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply