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:...

  • I really need help making a linked list program in C++, the program in total should...

    I really need help making a linked list program in C++, the program in total should have 3 source files: IntList.h IntList.cpp IntListTest.cpp The class should contain the following functions: Constructor Destructor (should use removeAll() function) insert(int) - inserts the given int into the list (in order, duplicates are allowed) remove(int) - removes the given int from the list. Returns true if successful, false otherwise. print() - prints the list in-order (all on one line, comma delimited; no comma at...

  • 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...

  • you’ll write a program to illustrate how Linked list and structure are used in practice, we’ll...

    you’ll write a program to illustrate how Linked list and structure are used in practice, we’ll develop a program that maintains a database of information about parts stored in a warehouse. The program is built around the database stored in linked list and structures, with each structure containing information - part number, name, and quantity – about one part. • The program tracks parts stored in a warehouse. • Contents of each structure: – Part number – Name – Quantity...

  • 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...

  • (WRITE THIS PROGRAM IN C LANGUAGE).Before I ask the question, i'm just letting you know that...

    (WRITE THIS PROGRAM IN C LANGUAGE).Before I ask the question, i'm just letting you know that I asked this question before but I unfortunately the answer was wrong, in fact, it didn't even answer my questions. So please make an effort to answer this question. In this question, we will learn about a variant of linked list called \doubly Linked List". In addition to the \next" pointer pointing to the next node in the list, a node in a doubly...

  • 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...

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