Please Someone help me Complete this Program I Included everything the instructo
ID: 3812919 • Letter: P
Question
Please Someone help me Complete this Program I Included everything the instructor gave me. Please Help this is Due by the end of the Day today.. and i cant figure it out!!
2. Problem Description: In this exercise, you are going to complete a program that organizes the order history information.
Two types of struct have been defined for you. They are order and customer. The relationship between them can be found by reading the code provided for you. If you have any questions, please ask the instructor.
The main program (order_application.cpp) and the header file (order.h) have been written for you. You task is to complete three functions in order.cpp.
void insert_to_head(order * & head, order * node)
o insert a node to the head of a linkedlist
parameter head is the head of the original linked list
parameter node is the new node
string search_customer_name_by_order_id(order * head, int order_id)
search the linked list pointed by head and return the customer name (first name, space, last name) who placed order order_id.
If no such order_id is found, return string “No Boday”
double total_orders_by_customer_id(order * head, int customer_id)
o search the linked list, return the total orders (cost) placed by customer_id
if no such customer id is found, return 0
The draft of the program is at
http://www.cs.iusb.edu/~yul/C201/source/hw5/order_application.cpp;
http://www.cs.iusb.edu/~yul/C201/source/hw5/order.h;
http://www.cs.iusb.edu/~yul/C201/source/hw5/order.cpp;
The executable is at http://www.cs.iusb.edu/~yul/C201/source/hw5/hw5.ex
Submission: Print the source code of order.cpp
order_application.cpp:
order.h:
order.cpp;
Explanation / Answer
Here's your order.cpp contents:
#include <iostream>
#include "order.h"
using namespace std;
void insert_to_head(order * & head, order * node)
{
node->next = head;
head = node;
}
void show_all_orders(order * head)
{
order * current_order = head;
cout << "............................................................ ";
cout << "Order ID Date Cost Customer ID Customber Name ";
cout << "............................................................ ";
while (current_order!=NULL)
{
cout << current_order->order_ID << " ";
cout << current_order->order_date << " ";
cout << current_order->cost << " ";
cout << current_order->CP->customer_ID << " ";
cout << current_order->CP->first_name + " " + current_order->CP->last_name << " ";
current_order = current_order->next;
}
cout << "........................................................... ";
return;
}
string search_customer_name_by_order_id(order * head, int order_id)
{
order *current = head;
while(current != NULL)
{
if(current->order_ID == order_id)
{
string name = current->CP->first_name + " " + current->CP->last_name;
return name;
}
current = current->next;
}
return "NO Body";
}
double total_orders_by_customer_id(order * head, int customer_id)
{
double total = 0;
order *current = head;
while(current != NULL)
{
if(current->CP->customer_ID == customer_id)
{
total = total+current->cost;
}
current = current -> next;
}
return total;
}
// Note: Please insert #include<cstdlib> header file at your main section to work with rand() function.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.