Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Used this code but could not even get it to run, also how do I get the program to open and read the file I
Used this code but could not even get it to run, also how do I get the program to open and read the file I need it to so it can input the numbers i need from the document. Need in C also please upload the whole code and pictures. No one can seem to find a comment section so if you know how to get to it please let me know, if not how else can I reach you to reply with anything else im having trouble with on this code? Im using devc IDE, Also can we no longer upload multiple pictures?
Assignment is in the picture provided
main file
LinkedList.cpp : Defines the entry point for the console application.
#include "List.h
#include
#include
#include
using namespace std;
int main
List list new List;
string line;
ifstream myfilenumberstxt;
if myfileisopen
while getlinemyfile line
listInsertstodline;
myfile.close;
else cout "Unable to open file";
listDisplay;
listDeletNegative;
listDisplay;
int index;
cout "Enter index to insert : ;
cin index;
double num;
cout "Enter number to insert : ;
cin num;
listInsertindex num;
listDisplay;
cout "Enter index to delete : ;
cin index;
listDeleteindex;
listDisplay;
return ;
List.cpp
#include "List.h
#include
using namespace std;
List::List
List::~List
void List::Insertint index, double value
int count ;
Node node root;
Node parent root;
if node NULL && index
return;
;
if node NULL && index
Node newnode new Node;
newnodedata value;
newnodenext NULL;
nodenext newnode;
return;
if node NULL && index
Node newnode new Node;
newnodedata value;
newnodenext node;
root newnode;
return;
while nodenext NULL
parent node;
node nodenext;
count;
if count index
break;
if count index
cout "invalid index" endl;
return;
if node NULL
Node newnode new Node;
newnodedata value;
newnodenext NULL;
newnodenext node;
parentnext newnode;
return;
void List::Insertdouble value
Node node root;
if node NULL
root new Node;
rootdata value;
rootnext NULL;
return;
;
while nodenext NULL
node nodenext;
Node newnode new Node;
newnodedata value;
newnodenext NULL;
nodenext newnode;
return;
void List::Deleteint index
int count ;
Node node root;
Node parent root;
if node NULL && index
cout "invalid index" endl;
return;
;
if node NULL && index
root nodenext;
return;
while nodenext NULL
parent node;
node nodenext;
count;
if count index
break;
if count index
cout "invalid index" endl;
return;
if node NULL
parentnext nodenext;
return;
void List::Display
Node node root;
if node NULL return;
while nodenext NULL
cout nodedata endl;
node nodenext;
cout nodedata endl;
return;
void List::DeletNegative
Node node root;
Node parent root;
if node NULL return;
while nodenext NULL
if nodedata
parentnext nodenext;
parent node;
node nodenext;
return;
List.h
#pragma once
struct Node
double data;
struct Node next;
;
class List
public:
List;
~List;
void Insertint index, double value;
void Insertdouble value;
void Deleteint index;
void Display;
void DeletNegative;
private:
Node root;
;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started