Question: I need Help Solving This Homework Problem Please someone help C201 Homework 6 Problem 1. This exercise is based on homework 5. Two types of

I need Help Solving This Homework Problem Please someone help

C201 Homework 6

Problem 1. This exercise is based on homework 5. 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. Your task is to complete one function in order.cpp.

void remove(order * & head, double limit)

o remove all the nodes from the linked list that have order cost greater than or equal to limit

The draft of the program is at

http://www.cs.iusb.edu/~yul/C201/source/hw6/order_application.cpp; http://www.cs.iusb.edu/~yul/C201/source/hw6/order.h; http://www.cs.iusb.edu/~yul/C201/source/hw6/order.cpp;

The executable is at

http://www.cs.iusb.edu/~yul/C201/source/hw6/hw6.ex

Submission: Print the source code of order.cpp and bring it to class

Problem 2. Write a program that manages student score. Your program should contain the definition of node of a linked list, a main function, a function to insert a node to the head of the linked list, a function to display student records, and a function to calculate the average score.

Details about this program is explained below

The node should contain data fields to represent the following student information: student ID (integer), first name, last name, and score (double and in the range of 0 to 100).

The main() function should create the head of the linked listed and ask the user to make the following selections:

Enter a record

Show records

Show average score

Terminate the program

If Option (a) is selected, the program should ask the user to enter the following information: ID, first name, last name, and score. The program should then create a node about the student and insert it to the head of the linked list through calling insert_to_head() function.

If Option (b) is selected, the program should call show_record() function to display all student records.

If Option (c) is selected, the program should call average() function and display the average score of all students.

If Option (d) is selected, the program should terminate.

You should code this program in a way so that it can continue to display the options for the user until the user choose Option (d)

The insert_to_head() function should insert the new node to the head of the linked list

The show_record() function should show all the nodes in the linked list.

The average() function should return the average score of the students in the list. If the list is empty, return 0.

The executable of the program is at http://www.cs.iusb.edu/C201/source/hw6/problem2.ex

Submission: Print the source code and bring it to cla

Problem 1:

Order_Application.cpp file

#include  #include  #include "order.h" using namespace std; int main() { order * head = NULL; for (int i=0; i<3; i++) { order * node = new order; customer * cu = new customer; node->order_ID = 10001 + i; node->order_date = "July 4, 2009"; node->cost = (100 + rand()%100)/10.0; cu->customer_ID = 20001 + i%2; cu->first_name = "Janet"; cu->last_name = "Smith"; node->CP = cu; node->next = NULL; insert_to_head(head, node); } show_all_orders(head); cout << " The customer who placed order 10002 is " << search_customer_name_by_order_id(head, 10002) << endl; cout << " The total orders by customer 20001 is $" << total_orders_by_customer_id(head, 20001) << endl; remove_node(head, 15); cout << " The orders that are less than $15 are listed below: "; show_all_orders(head); return 0; } 

order.h file

#include  using namespace std; struct customer { int customer_ID; string first_name; string last_name; }; struct order { int order_ID; string order_date; double cost; customer * CP; order * next; }; void insert_to_head(order * & head, order * node); void show_all_orders(order * head); string search_customer_name_by_order_id(order * head, int order_id); double total_orders_by_customer_id(order * head, int customer_id); void remove_node(order * & head, double limit); 

order.cpp file

#include  #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\tDate\tCost\tCustomer ID\tCustomber Name "; cout << "............................................................ "; while (current_order!=NULL) { cout << current_order->order_ID << "\t"; cout << current_order->order_date << "\t"; cout << "$" << current_order->cost << "\t"; cout << current_order->CP->customer_ID << "\t"; 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_order = head; while (current_order!=NULL) { if(current_order->order_ID == order_id) { return current_order->CP->first_name + " " + current_order->CP->last_name; } current_order = current_order->next; } return "No Boday"; } double total_orders_by_customer_id(order * head, int customer_id) { order * current_order = head; double total=0; while (current_order!=NULL) { if(current_order->CP->customer_ID == customer_id) { total = total + current_order->cost; } current_order = current_order->next; } return total; } void remove_node(order * & head, double limit) { //Remove the nodes that have order cost greater than or equal to limit //Your code goes here } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!