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

I need to create a program that will store subject information (sorted by subjec

ID: 3574105 • Letter: I

Question

I need to create a program that will store subject information (sorted by subject) from the user, build a linear linked list inserting the data in sorted order, and display the information (traversing the entire LLL). It should continue to do this as long as the user wants. you are not allowed to use global variables or breaks You may not use the string class – instead use arrays of characters. You are allowed to use the cstring library. Make sure to use C++’s I/O (iostream library) for your input and output. After each input operation, make sure to use cin.ignore to remove the delimiters! - i cannot use external files at all separate out your code into a .h file and at least two .cpp files. The .h file should contain the (a) #includes, (b) constants, (c) prototypes, (d) struct definitions, and (e) class interface(s) – if you are using a class. Your struct node should be placed in the .h file. Never place the implementation of your functions in a .h file; these belong in a .cpp file!

for traversing the pointer name should be "next "

the Pointer name at the beginning of the list should be named "head" of the list

the big picture is to create a LLL and display it.

Explanation / Answer

Your program is as below :

Subjects.h
#include <iostream>
#include < string>
#include <iomanip>
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#ifndef Subjects_H
#define Subjects_H
using name space std;
class Subjects ;
ostram &operator << (ostream &, const Subjects &);
istream &operator >> (istream &, Students &);

class Subjects{
private :
string subname;
string subdetails;
public :
//Constructor
Subjects(string a,string b)
{
   subname = a;
   subdetail = b;
}
friend ostream &operator << (ostream &, const Subjects &);
friend istream &operator >> (istream &, Students &);
};
#endif

LinkedList.cpp
#include "LLL.h"
using namespace std;
template <class T>
class LinkedList
{
private :
struct Listnode
{
   T value;
   struct ListNode *next;
};
ListNode *head;
public :
//constructor
LinkedList()
{head = NULL;}
//destructor
~LinkedList();
//Linked List operations
void appendNode(T);
void displayList() const;
};
//append node appends a node containing the value.
template <class T>
void LinkedList<T> :: appendNode(T newValue)
{
   ListNode *newNode;
   ListNode *nodePtr;
newNode = new ListNode;
newNode -> value = newValue;
newNode->next = NULL;
//If there are no nodes in the list
//make newNode the first node.
if(!head)
   head = newNode;
else{   //insert new node at the end
   nodePtr = head;
   while(nodePtr->next)
   nodePtr = nodePtr->next;
   nodePtr->next = newNode;
}
}
//Display the value of linked list
template <class T>
void LinkedLust<T>::displayList() const
{
   ListNode *nodePtr; //to move through list
nodePtr = head;
while(nodePtr)
{
   cout << nodePtr->value << endl;
nodePtr = nodePtr->next;
}
}


main.cpp
#include "LLL.h"
#include "Linkedlist.cpp"
using namespce std;
int main()
{
   string a,b;
   //define object of linked list
   LinkedList<Subjects> List;
   //define some objects
   Subjects sub1("maths","maths is very good subject");  
   subjects sub2("english","english is the most widely used language");
   cout << "Enter subject name :" << endl;
   cin >> a;
   cout << "Enter subject details :" <<endl;
   cin >>b;
   Subjects sub3(a,b);
   list.appendNode(sub1);
   list.appendNode(sub2);
   list.appendNode(sub3);
cout << "here is the information to display :";
list.displayList();
cout << endl;
return 0;
}

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