C++, any help would be appreciated. Everything I do doesn't want to work. Thanks
Create a linked list program with a .h and a .cpp file. A menu is needed like below and the print list should just print the list. Print order summary, an example is bellow butt a cookie and amount would be great. And Exit is to well exit.
1. Print Ordering Summary
2. Print List
3. Exit
This is what will be in the text file for example and there will be more than that.
Allia Ramez
3
1 Thin Mint
2 Carmel Delite
Samuel Hardash
5
2 Shortbread
1 Lemonade
2 Carmel Delite
Code to help:
struct CookieNode
{
char cookie_name[COOKIE_NAME_SIZE];
int num_boxes;
char customer_name[CUSTOMER_NAME_SIZE];
CookieNode * next;
};
Order summary example
|
Cookie Names |
Number of Boxes |
|
Carmel Delight |
4 |
|
Lemonade |
1 |
|
Shortbread |
2 |
|
Thin mint |
1 |
Hi,
Creating a full program for this project is too big, and probably out of scope of HomeworkLib answer. As you have asked for help, i will try to help you in short on how you should approach your project..
What you will do is basically:
1. Read the input file data. Then you need to parse the data, so that you get to know what a customer wants.
2. What i see is, it seems, there are some constant number of products, like Carmel Delight, Lemonade etc.
And a customer can order any quantity of any item. What i see from you current struct is, You are creating a node to store only one item and its quantity along with customer info..
Why don't you use below structure:
// assuming there are only 4 items
struct CookieNode {
char cookie_name[4][COOKIE_NAME_SIZE];
int num_boxes[4];
float prices[4];
char customer_name[CUSTOMER_NAME_SIZE];
CookieNode * next;
};
What above node does is, it stores a customer name, and for all of the items, it stores how much quantity customer wants, and what is the unitprice of each product. In this way, there will be just one node for each customer in the linkedList. And also, it sotres the link to next linkedlist node.
3. As You need to print the order Summary, what you need to do is, traverse the linkedList and keep on calculating the quantity ordered for a product..
Like "Carmel Delight" is at index 1, so to find total quantity of "Carmel Delight", we can traverse the list and sum the num_boxes[0] value in each node. Similarly for other items. As you wanted the cost of the items too, that You can do by summing num_boxes[0] * prices[0] on the node. That way you will get total price for "Carmel Delight".
4. you want to print list, that should be straight forward now, as one customer is inside one node only.. So you can visit each node, and based on num_boxes, you can print the details of what that customer wants.
I have tried to answer your question fundamentally, If you want more specific details such as code etc, I would suggest you to please post small questions in separate thread on HomeworkLib. Let me know if it helps, or any issues. Thanks!
C++, any help would be appreciated. Everything I do doesn't want to work. Thanks Create a...
Writing a program in C please help!! My file worked fine before but when I put the functions in their own files and made a header file the diplayadj() funtion no longer works properly. It will only print the vertices instead of both the vertices and the adjacent like below. example input form commnd line file: A B B C E X C D A C The directed edges in this example are: A can go to both B and...
hi, please help in c++.
I dont understand how to do this, and a lot of the ways on the
internet is confusing me, i am a beginner.
with all steps and explantions, will rate!
Write a program that determines the frequency of each char in an input file. Your program should . read in an unknown number of chars from an input file named input.txt, • using a function written by you, determine the frequency of occurrence of each...
I need help implementing class string functions, any help would be appreciated, also any comments throughout would also be extremely helpful. Time.cpp file - #include "Time.h" #include <new> #include <string> #include <iostream> // The class name is Time. This defines a class for keeping time in hours, minutes, and AM/PM indicator. // You should create 3 private member variables for this class. An integer variable for the hours, // an integer variable for the minutes, and a char variable for...
Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...
Hi, it's C++ question. Only can use <iostream> and <fstream>libraries Please help me, thanks Question Description: For this project you will write a program to: a) read-in the 10 first names from a file (the file is a priori given to have exactly 10 entries, of a maximum length of 8 letters each) into a 2-dimensional character array, b) output the names to the terminal with each one preceded by a number indicating its original order in the list, c)...
Need this in C
The starter code is long, if you know how to do it in other way
please do.
Do the best you can please.
Here's
the starter code:
//
-----------------------------------------------------------------------
// monsterdb.c
//
-----------------------------------------------------------------------
#include
#include
#include
//
-----------------------------------------------------------------------
// Some defines
#define NAME_MAX 64
#define BUFFER_MAX 256
//
-----------------------------------------------------------------------
// Structs
typedef struct
{
char name[NAME_MAX];
int hp;
int attackPower;
int armor;
} Character;
typedef struct
{
int size;
Character *list;
} CharacterContainer;
//
-----------------------------------------------------------------------
//...
c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...
Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...
C++ program: can you help create a autocorrect code using the cpp code provided and the words below using pairs, vectors and unordered map: Objectives To practice using C++ std::pair, std::vector, and std::unordered_map To tie together what we've learned into the context of a real-world application used by millions of people every day Instructions For Full Credit You're given a short list of words in known_words_short.txt that contains a handful of very different words. Assume this short list of words...
I am getting the Segmentation fault error on the Ubuntu machine
but not on macOS.
Any help would be appreciated.
/**** main.c ****/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <pthread.h>
#include <string.h>
#define WORD_LEN 6
#define TOP 10
char * delim = "\"\'.“”‘’?:;-,—*($%)! \t\n\x0A\r";
struct Word {
char word[30];
int freq;
};
int threadCount;
int fileDescriptor;
int fileSize;
off_t chunk;
struct Word* wordArray;
int arrIndex = 0;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;...