Question

C++ really need help I will rate you well promise Write a program that will use...

C++ really need help I will rate you well promise

Write a program that will use a linked list to hold the following information:

Date (int), Time (int), TZ (string), Size (Int) and Name (string)

Follow the guidelines below:

Records should be read from a file by the main program. And content should be stored in the doubly linked list or single linked list.

After that, you can print separately dates or times or names ... or print hole line  

Use the following information for testing purposes:

Date Time TZ Size Name

1/18/2002 4:44:00 AM 232758 ARIALUNI.TTF

7/18/2008 3:15:00 AM 133424 zelan.ttf

7/18/2008 3:13:00 AM 148188 hiwua.ttf

7/18/2008 3:14:00 AM 162396 fantuwua.ttf

7/18/2008 3:12:00 AM 162504 tint.ttf

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The date and time in the program are in a format so they are taken as string please comment if you have any doubts

#include<iostream>
#include<fstream>
#include<string>
#include<stdlib.h>
#include<vector>
#include <cstdlib>
#include <sstream>
using namespace std;
struct node
{
   string date;
   string time;
   string TZ;
   string name;
   int size;
   struct node *next;
};
void tokenize(string const &str, const char delim,
           vector<string> &out)
{
   size_t start;
   size_t end = 0;

   while ((start = str.find_first_not_of(delim, end)) != std::string::npos)
   {
       end = str.find(delim, start);
       out.push_back(str.substr(start, end - start));
   }
}

class linked_list
{
private:
node *head,*tail;
public:
linked_list()
{
head = NULL;
tail = NULL;
}

void add_node(string date, string time, string TZ, int size, string name)
{
node *tmp = new node;
   tmp->date = date;
   tmp->time = time;
   tmp->TZ = TZ;
   tmp->size = size;
   tmp->name = name;
tmp->next = NULL;

if(head == NULL)
{
head = tmp;
tail = tmp;
}
else
{
tail->next = tmp;
tail = tail->next;
}
}
void display()
{
   node *current = head;
   while(current != NULL)
   {
       cout<<current->date<<endl;
       cout<<current->time<<endl;
       cout<<current->TZ<<endl;
       cout<<current->size<<endl;
       cout<<current->name<<endl;
       current = current -> next;
   }
}
};

int main()
{
   ifstream file("data.txt");
   string str;
   getline(file, str);
   getline(file, str);
   while(str != "")
   {
        const char delim = ' ';
       vector<string> out;
       tokenize(str, delim, out);
       stringstream convert(out[3]);
       int size;
       convert >> size;
       linked_list a;
       a.add_node(out[0], out[1], out[2], size, out[4]);
       getline(file, str);
       a.display();
      
      
   }
}

If you have any doubts please comment and please don't dislike

Add a comment
Know the answer?
Add Answer to:
C++ really need help I will rate you well promise Write a program that will use...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE WRITE IN JAVA AND ADD COMMENTS TO EXPLAIN write a class NameCard.java which has •Data...

    PLEASE WRITE IN JAVA AND ADD COMMENTS TO EXPLAIN write a class NameCard.java which has •Data fields: name (String), age(int), company(String) •Methods: •Public String getName(); •Public int getAge(); •Public String getCom(); •Public void setName(String n); •Public void setAge(int a); •Public void setCom(String c); •toString(): \\ can be used to output information on this name card 2, write a class DoublyNameCardList.java, which is a doubly linked list and each node of the list a name card. In the DoublyNameCardList.java: •Data field:...

  • the language i wan used in C# is visual basic.Create a console program that contains the...

    the language i wan used in C# is visual basic.Create a console program that contains the following ·         A Class named Account with the following properties: o   public int Id { get; set; } o   public string Firstname { get; set; } o   public string Lastname { get; set; } o   public double Balance { get; set; } o   public DateTime CreationDate { get; set; } o   Create a constructor that initializes all of the properties. o   Create a ToString...

  • C++ program, item.cpp implementation. Implementation: You are supposed to write three classes, called Item, Node and In...

    C++ program, item.cpp implementation. Implementation: You are supposed to write three classes, called Item, Node and Inventory respectively Item is a plain data class with item id, name, price and quantity information accompanied by getters and setters Node is a plain linked list node class with Item pointer and next pointer (with getters/setters) Inventory is an inventory database class that provides basic linked list operations, delete load from file / formatted print functionalities. The majority of implementation will be done...

  • Need help creating a basic java string program using nested if/else, return loops or while loops...

    Need help creating a basic java string program using nested if/else, return loops or while loops or charAt methods while returning information using a console, Please leave notes as to compare my program and see where I went wrong or could've used a different method. secondsAfterMidnight Input: String that represents time of day Returns: integer number of seconds after midnight (return -1 if String is not valid time of day) General time of day format HH:MM:SS(AM/PM) These are examples where...

  • In this lab, you will write a program that reads a series name/value pairs, and stores...

    In this lab, you will write a program that reads a series name/value pairs, and stores them in a pair of vectors. After the name/value pairs are read, it will then read names (until the input is exhausted) and print out the corresponding value for that name. If the name is not found in the list, "name not found" should be printed. The names should be read as strings and stored as a vector<string>; the values should be read as...

  • I need this in C++. This is all one question Program 2: Linked List Class For...

    I need this in C++. This is all one question Program 2: Linked List Class For this problem, let us take the linked list we wrote in a functional manner in a previous assignment and convert it into a Linked List class. For extra practice with pointers we'll expand its functionality and make it a doubly linked list with the ability to traverse in both directions. Since the list is doubly linked, each node will have the following structure: struct...

  • Hi this is C++, I'm really struggle with it please help me.... ************************ Here is the...

    Hi this is C++, I'm really struggle with it please help me.... ************************ Here is the original high score program,: Write a program that records high-score data for a fictitious game. The program will ask the user to enter five names, and five scores. It will store the data in memory, and print it back out sorted by score. The output from your program should look exactly like this: Enter the name for score #1: Suzy Enter the score for...

  • For C++, This is part of a larger program but I only need help with writing...

    For C++, This is part of a larger program but I only need help with writing and calling this function. I am having trouble finding information on calling a 2d vector. Given : const int NUM_STUDENTS =3; string Students[NUM_STUDENTS] = {"Tom","Jane","Jo"}; vector <int> grades[NUM_STUDENTS] {{78,98,88,99,77},{62,99,94,85,93}, {73,82,88,85,78}}; 4. Write a function called displayGrades that takes the student array and grade vector as parameters and displays the grades in the format in the sample run below. (15 points). Output: Name Assign. 1...

  • Please use C programming to write the code to solve the following problem. Also, please use the i...

    Please use C programming to write the code to solve the following problem. Also, please use the instructions, functions, syntax and any other required part of the problem. Thanks in advance. Use these functions below especially: void inputStringFromUser(char *prompt, char *s, int arraySize); void songNameDuplicate(char *songName); void songNameFound(char *songName); void songNameNotFound(char *songName); void songNameDeleted(char *songName); void artistFound(char *artist); void artistNotFound(char *artist); void printMusicLibraryEmpty(void); void printMusicLibraryTitle(void); const int MAX_LENGTH = 1024; You will write a program that maintains information about your...

  • Using the program segment and sample txt file below, write a program that contains a linked...

    Using the program segment and sample txt file below, write a program that contains a linked list of students. The program should allow the user to: 1. initialize list of students 2. add additional student to front of list 3. add additional student to rear of list 4. delete student 5. sort students alphabetically 6. sort students by idNum 7. show number of students in list 8. print students 9. quit program XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The program should be divided into the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT