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

Hello, can some one please help. please leave comments conversion code is almost

ID: 3598449 • Letter: H

Question

Hello, can some one please help.

please leave comments

conversion code is almost identical to the display code, with the following exceptions:

1) delete the existing entries in the destination list (e.g., if doing single to double, you would delete the destination list entries)

2) for each entry in the source list, grab its student data, and append a new node (with the same student data) to the destination list

and that's it

heres my code

//

// student.h

// studentlist

#ifndef student_h

#define student_h

#include <iostream>

#include <fstream>

#include <iomanip>

#include <string>

class student {

public:

student();

student(const std::string& lname, const std::string& fname, float gpa, int cwid);

  

std::string lname() const;

std::string fname() const;

float gpa() const;

int cwid() const;

  

void gpa(float gpa);

  

friend std::ostream& operator<<(std::ostream& os, const student& st);

friend std::istream& operator>>(std::istream& is, student& st);

  

private:

std::string lname_;

std::string fname_;

float gpa_;

int cwid_;

};

#endif /* student_h */

//

// studentNode.h

// studentlist

#ifndef studentNode_h

#define studentNode_h

#include <iostream>

#include <string>

#include "student.h"

struct studentNode {

studentNode(const std::string& lname, const std::string& fname, float gpa, int cwid, studentNode* next=nullptr);

studentNode(const student& st, studentNode* next=nullptr);

  

friend std::ostream& operator<<(std::ostream& os, const studentNode& node);

  

  

student st_;

studentNode* next_;

};

#endif /* studentNode_h */

//

// dstudentNode.h

// studentlist

//

//

#ifndef dstudentNode_h

#define dstudentNode_h

#include <iostream>

#include <string>

#include "student.h"

struct dstudentNode {

dstudentNode(const std::string& lname, const std::string& fname, float gpa, int cwid,

   dstudentNode* next=nullptr, dstudentNode* prev=nullptr);

  

dstudentNode(const student& st, dstudentNode* next=nullptr, dstudentNode* prev=nullptr);

  

friend std::ostream& operator<<(std::ostream& os, const dstudentNode& node) ;

  

  

student st_;

dstudentNode* next_;

dstudentNode* prev_;

};

#endif /* dstudentNode_h */

//

// studentList.h

// studentlist

//

//

#ifndef studentList_h

#define studentList_h

#include <iostream>

#include <sstream>

#include <fstream>

#include <iomanip>

#include <string>

#include <cstring>

#include <stack>

#include "studentNode.h"

struct studentList {

studentList();

  

void display();

void prepend(studentNode* node);

void prepend(const std::string& lname, const std::string& fname, float gpa, int cwid);

void append(studentNode* node);

void append(const std::string& lname, const std::string& fname, float gpa, int cwid);

void insertAt(size_t index, studentNode* node);

void insertAt(size_t index, const std::string& lname, const std::string& fname, float gpa, int cwid);

  

void deleteAt(size_t index);

void deleteAll();

  

void popfront();

void popback();

  

studentNode* front();

studentNode* back();

  

void rotateLeft(size_t n);

void rotateRight(size_t n);

void reverse();

  

void write(const std::string& filename);

void read(const std::string& filename);

  

static void test();

  

studentNode* head_;

size_t size_;

};

#endif /* studentList_h */

//

// dstudentList.hpp

// studentlist

//

#ifndef dstudentList_hpp

#define dstudentList_hpp

#include <iostream>

#include "dstudentNode.h"

struct dstudentList {

dstudentList();

  

void display();

void prepend(dstudentNode* node);

void prepend(const std::string& lname, const std::string& fname, float gpa, int cwid);

  

void append(dstudentNode* node);

void append(const std::string& lname, const std::string& fname, float gpa, int cwid);

  

void insertAt(size_t index, dstudentNode* node);

void insertAt(size_t index, const std::string& lname, const std::string& fname, float gpa, int cwid);

  

void deleteAll();

void deleteAt(size_t index);

void popfront();

void popback();

dstudentNode* front();

dstudentNode* back();

void rotateLeft(size_t n);

void rotateRight(size_t n);

void swap(dstudentNode*& p, dstudentNode*& q);

void reverse();

void write(const std::string& filename);

void read(const std::string& filename);

static void test();

  

  

dstudentNode* head_;

dstudentNode* tail_;

size_t size_;

};

#endif /* dstudentList_hpp */

//

// convertLists.h

// studentlist

#ifndef convertLists_h

#define convertLists_h

#include <iostream>

#include "studentList.h"

#include "dstudentList.h"

void convertSingle_toDouble(const studentList& sli, dstudentList& dli);

void convertDouble_toSingle(const dstudentList& dli, studentList& sli);

#endif /* convertLists_h */

//

// read_hints.cpp

// studentListClasses

//

// Created by William McCarthy on 10/19/17.

// Copyright © 2017 William McCarthy. All rights reserved.

//

//#include <fstream>

//

//// in student.h, *inside* the student class ============================================

////...

//friend std::istream& operator>>(std::istream& is, student& st);

////...

//

//// in student.cpp -- it's an istream operator ============================================

//std::istream& operator>>(std::istream& is, student& st) {

// std::string gpa, cwid;

// is >> st.lname_ >> st.fname_ >> st.gpa_ >> st.cwid_;

// is.ignore();

//

// return is;

//}

//

//// in studentList.cpp ============================================

//void studentList::read(const std::string& filename) {

// std::ifstream ifs;

// ifs.open(filename, std::ifstream::in);

//

// student st;

// while (ifs.peek() != EOF) {

// ifs >> st;

// std::cout << " read back from file: " << st;

// append(new studentNode(st));

// }

// ifs.close();

//}

Explanation / Answer

ifndef dstudentList_hpp

#define dstudentList_hpp

#include <iostream>

#include "dstudentNode.h"

struct dstudentList {

dstudentList();

  

void display();

void prepend(dstudentNode* node);

void prepend(const std::string& lname, const std::string& fname, float gpa, int cwid);

  

void append(dstudentNode* node);

void append(const std::string& lname, const std::string& fname, float gpa, int cwid);

  

void insertAt(size_t index, dstudentNode* node);

void insertAt(size_t index, const std::string& lname, const std::string& fname, float gpa, int cwid);

  

void deleteAll();

void deleteAt(size_t index);

void popfront();

void popback();

dstudentNode* front();

dstudentNode* back();

void rotateLeft(size_t n);

void rotateRight(size_t n);

void swap(dstudentNode*& p, dstudentNode*& q);

void reverse();

void write(const std::string& filename);

void read(const std::string& filename);

static void test();

  

  

dstudentNode* head_;

dstudentNode* tail_;

size_t size_;

};

#endif /* dstudentList_hpp */

//

// convertLists.h

// studentlist

#ifndef convertLists_h

#define convertLists_h

#include <iostream>

#include "studentList.h"

#include "dstudentList.h"

void convertSingle_toDouble(const studentList& sli, dstudentList& dli);

void convertDouble_toSingle(const dstudentList& dli, studentList& sli);

#endif /* convertLists_h */

//

// read_hints.cpp

// studentListClasses

//

// Created by William McCarthy on 10/19/17.

// Copyright © 2017 William McCarthy. All rights reserved.

//

//#include <fstream>

//

//// in student.h, *inside* the student class ============================================

////...

//friend std::istream& operator>>(std::istream& is, student& st);

////...

//

//// in student.cpp -- it's an istream operator ============================================

//std::istream& operator>>(std::istream& is, student& st) {

// std::string gpa, cwid;

// is >> st.lname_ >> st.fname_ >> st.gpa_ >> st.cwid_;

// is.ignore();

//

// return is;

//}

//

//// in studentList.cpp ============================================

//void studentList::read(const std::string& filename) {

// std::ifstream ifs;

// ifs.open(filename, std::ifstream::in);

//

// student st;

// while (ifs.peek() != EOF) {

ifs >> st;

std::cout << " read back from file: " << st;

append(new studentNode(st));

}

ifs.close();

}

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