Can someone help me create a function to print all items with a Prod_Stockcount less than 5? Its missing some code but all you need is to add and then create a function to print items with stockcount less than 5
# include <stdio.h>
# include <string.h>
# include <iostream>
# include <fstream>
#include <stdlib.h>
# include <cstring>
using namespace std;
// Declare Global Variable
struct node {
int Prod_Id ;
char Prod_Name [20];
char Prod_Category [10];
char Prod_Supplier [20];
float Prod_WholeSalePrice ;
float Prod_RetailSalePrice ;
float Prod_CostPrice;
int Prod_stockcount;
int order;
node *next;// Pointer to next node
} product;
node *start_ptr = NULL;
node *temp1, *temp2;
node *current;
int rec_num ;
//###########################################
void addproduct () {
string tempValue;
bool ok;
ofstream PRODUCT ("PRODUCT.txt", ios::app|ios::out);
//data to be added to file
//record number
temp1 = new node;
cout <<"\nAdd Product \n";
rec_num++; //add one to customer count
cout << "\n##### New Product #####";
cout << "\nRecord Number: " << rec_num;
//validation to check field length
ok=false;
do{
cout << "\nEnter Product ID: ";
cin >> tempValue;
temp1->Prod_Id = atoi(tempValue.c_str());
if (temp1->Prod_Id = atoi(tempValue.c_str())){
ok=true;}
else{
ok=false;
cout << "Invalid Numeric Value!";
}
}while(ok!=true);
PRODUCT << temp1->Prod_Id << endl;
//**************
//validation to check field length
ok = false;
do{
cout <<"\nEnter Product Name: ";
cin >> tempValue;
//input
//checks to see if length of first name was exceeded
if(tempValue.length()>20){
ok=false;
cout <<"\nProduct Name Too Long!";
}else{
ok=true;
}
}while(ok!=true);
strcpy(temp1->Prod_Name, tempValue.c_str());
PRODUCT << temp1->Prod_Name << endl;
//**************
//validation to check field length
ok = false;
do{
cout <<"\nEnter Product Category: ";
cin >> tempValue;
//input
//checks to see if length of first name was exceeded
if(tempValue.length()>10){
ok=false;
cout <<"\nProduct Category Name Too Long!";
}else{
ok=true;
}
}while(ok!=true);
strcpy(temp1->Prod_Category, tempValue.c_str());
PRODUCT << temp1->Prod_Category<< endl;
//**************
//validation to check field length
ok = false;
do{
cout <<"\nEnter Supplier Name: ";
cin >> tempValue;
if(tempValue.length()>20){
ok=false;
cout <<"\nProduct Supplier Name is Too Long!";
}else{
ok=true;
}
}while(ok!=true);
strcpy(temp1->Prod_Supplier, tempValue.c_str());
PRODUCT << temp1->Prod_Supplier<< endl;
//**************
//validation for numeric fields
ok=false;
do{
cout << "\nEnter Whole Sale Price: ";
cin >> tempValue;
temp1->Prod_WholeSalePrice = atof(tempValue.c_str());
if (temp1->Prod_WholeSalePrice = atof(tempValue.c_str())){
ok=true;}
else{
ok=false;
cout << "Invalid Numeric Value!";
}
}while(ok!=true);
PRODUCT << temp1->Prod_WholeSalePrice<< endl;
//**************
//validation for numeric fields
ok=false;
do{
cout << "\nEnter Retail Sale Price: ";
cin >> tempValue;
temp1->Prod_RetailSalePrice = atof(tempValue.c_str());
if (temp1->Prod_RetailSalePrice = atof(tempValue.c_str())){
ok=true;}
else{
ok=false;
cout << "Invalid Numeric Value!";
}
}while(ok!=true);
PRODUCT << temp1->Prod_RetailSalePrice<< endl;
//**************
//validation for numeric fields
ok=false;
do{
cout << "\nEnter Number of products in stock: ";
cin >> tempValue;
temp1->Prod_stockcount = atoi(tempValue.c_str());
if (temp1->Prod_stockcount = atoi(tempValue.c_str())){
ok=true;}
else{
ok=false;
cout << "Invalid Numeric Value!";
}
}while(ok!=true);
PRODUCT << temp1->Prod_stockcount<< endl;
//**************
//validation for numeric fields
ok=false;
do{
cout << "\nEnter OutStanding Order: ";
cin >> tempValue;
temp1->order = atoi(tempValue.c_str());
if (temp1->order = atoi(tempValue.c_str())){
ok=true;}
else{
ok=false;
cout << "Invalid Numeric Value!";
}
}while(ok!=true);
PRODUCT << temp1->order<< endl;
//**************
//validation for numeric fields
ok=false;
do{
cout << "\nEnter Cost Price: ";
cin>>tempValue;
temp1->Prod_CostPrice = atof(tempValue.c_str());
if (temp1->Prod_CostPrice = atof(tempValue.c_str())){
ok=true;}
else{
ok=false;
cout << "Invalid Numeric Value!";
}
}while(ok!=true);
PRODUCT << temp1->Prod_CostPrice<< endl;
//**************
temp1->next = NULL;
//set up link to this node
if (start_ptr == NULL)
start_ptr = temp1;
else {
temp2 = start_ptr;
//we know this is not NULL - list not empty!
while (temp2->next != NULL){
temp2 = temp2->next;//move to next link in chain
}
temp2->next = temp1;
}
}//end addpRODUCT
//*************************************************************
void read (){
}//end
//*************************************************
//**************
void findProduct() {
node *current;
int target;
bool found;
cout << "\n**********************Find Product******************** ";
cout << "\nEnter Product Id: ";
cin >> target;
found = false;
current = start_ptr;
if (current == NULL)
cout << "The list is empty!" << endl;
else {
while (current != NULL && found==false) {
if (target == current->Prod_Id){ //display customer
found = true;
cout << "\nProduct ID: " << current->Prod_Id;
cout << "\nProduct Name: " << current->Prod_Name;
cout << "\nProduct Category: " << current->Prod_Category;
cout << "\nProduct's Supplier: " << current->Prod_Supplier;
cout << "\nWhole Sale Price: " << current->Prod_WholeSalePrice;
cout << "\nRetail Price: " << current->Prod_RetailSalePrice;
cout << "\nCost Price: " << current->Prod_CostPrice;
cout << "\nNumber In Stock: " << current->Prod_stockcount;
cout << "\nOutstanding Order: " << current->order;
cout << endl;
}
current = current->next;
}
if (found==false) cout << "\nNo Matching Customer Found!" << endl;
}
}//end of findCustomer
//******************
void viewAll() {
cout << "\n##### View ALL #####";
temp1 = start_ptr;
while (temp1 != NULL) { // Display details for what temp points to
cout << "\nProduct ID: " << temp1->Prod_Id;
cout << "\nProduct Name: " << temp1->Prod_Name;
cout << "\nProduct Category: " << temp1->Prod_Category;
cout << "\nProduct's Supplier: " << temp1->Prod_Supplier;
cout << "\nWhole Sale Price: " << temp1->Prod_WholeSalePrice;
cout << "\nRetail Price: " << temp1->Prod_RetailSalePrice;
cout << "\nCost Price: " << temp1->Prod_CostPrice;
cout << "\nNumber In Stock: " << temp1->Prod_stockcount;
cout << "\nOutstanding Order: " << temp1->order;
cout << endl;
temp1 = temp1 -> next;
}
cout << "\nEnd of list!" << endl;
cout << "\nIF LIST IS EMPTY, PLEASE INITIALIZE FILE!" << endl;
}//end of viewAll
//############################################
void deleteProduct() {
}//end of deleteProduct
//############################################
int main (void){
//Declare local variables
char choice;
do {
cout << "******MAIN MENU******\n";
cout << "Choose One of the Following:\n";
cout << "(1) Add Product\n";
cout << "(2) Find Product\n";
cout << "(3) View All Records\n";
cout << "(4) Delete Product\n";
cout << "(5) Initialize Files\n";
cout << "(6) Exit\n";
cin >> (choice);
switch (choice) {
case '1':
addproduct ();
break;
case '2':
findProduct ();
break;
case '3':
viewAll();
break;
case '4':
deleteProduct();
break;
case '5':
read ();
break;
case '6':
exit (0);
break;
}//end switch
} while(choice != '6');
return 0;
}//end of main