Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help converting this c++ code into pseudocode to understand it better for

ID: 3912392 • Letter: P

Question

Please help converting this c++ code into pseudocode to understand it better for my assignment

/* No Prototype is declared because main Function is used in last */

/* Program Shows modularity using function */

//Including Header Files

#include "fstream"

#include "iostream"

#include "stdio.h"

#include "stdio.h"

using namespace std;

//Structure for maintaining customer order details

struct customer_code

{

int order_no, item_no, qty;

char customer_name[40], ship_code;

float ext_price;

}cc; //Declaring structure globally

//structure for maintaining shipping details

struct ship_codes

{ char code, ship_type[40];

float rate;

};

//globally declaring Structured array

//initialising Structured array with the codes given

ship_codes sc[] = { {'C', "Customer Pick-up", 00.00 },

{'P', "Parcel Post", 6.25 },

{'R', "Federal Express", 18.55},

{'U', "UPS Ground", 10.95},

{'M', "Overnight Mail", 12.50},

{'A', "Air Borne Exp", 14.95}

} ;

//Function to clear ' ' from buffer

int clear()

{

while ((getchar())^' ');   

}

/*

//Function to take input of ordered details to write them to disk

void getstock()

{ float unit_price;

cout<<" Enter Order Number : "; cin>>cc.order_no;

printf(" Enter Customer Name : ");

clear();

gets(cc.customer_name);

cout<<" Enter Item Number : "; cin>>cc.item_no;

cout<<" Quantity: "; cin>>cc.qty;

cout<<" Enter Unit Price : "; cin>>unit_price;

cc.ext_price=unit_price*cc.qty;

cout<<" Enter Ship code : "; cin>>cc.ship_code;

}

*/

//Function to display order details

void showstock()

{ cout<<"Computer R Us Current Open Order";

cout<<" Customer Name : "; puts(cc.customer_name); //puts() - library function to get input of string

cout<<"Order Number : "<<cc.order_no;

cout<<" Item Number : "<<cc.item_no;

cout<<" Quantity Ordered : "<<cc.qty;

cout<<" Unit Price : "; cout<<(cc.ext_price/cc.qty); //Calculating Unit Price from the Ext Price

cout<<" Ext. Price : "; cout<<cc.ext_price;

}

/*

//Funtion to take and write order details to files

void write_to_file()

{ char ch;

fstream file("customerOrder.dat", ios::binary|ios::app);

do

{ getstock();

file.write((char*)&cc,sizeof(cc));

cout<<" Want to Add more items (Y/N) : ";

cin>>ch;

} while(ch=='Y'||ch=='y');

file.close();

}

*/

void read_file()

{ ifstream file("customerOrder.dat",ios::binary); //File opening mode is binary

while(file.read((char*)&cc,sizeof(cc))) //Library function to fetch structured details from file

{

showstock(); //Displaying details on the screen

int a=0;

while(1)

{ if(cc.ship_code==sc[a].code)

{

cout<<" Shipping Cost : "<<sc[a].rate; //Displaying Shipping cost from

cout<<" Ordered Total : "<<cc.ext_price+sc[a].rate; //Calculating and displaying ordered Total

break;

}

a++;

}

}

}

int main() //decalaring Main function

{ read_file();

return 0;

}

Explanation / Answer

Please find the pseudocode/algorithm below.

1. Create a structure to represent Customer code. This structure will contain fields for storing customer order details, namely, Customer name, Ship code, order number, Item number, quantity, Extra price.

2. Now create another structure for storing shipping details. This structure will have fields for Shipping code, shipping type and the rate. Create an array of this structure and store all the shipping details into this array. These details are hardcoded instead of taking input from the user.

3. Now, get input the customer order details from the user and write the order details into file "customerOrder.dat". Keepon taking input from the user until he wishes to quit.

4. Now open the file "customerOrder.dat" in read mode.

5. Each of the lines in this file represents a Customer order. For each customer order, do the following:

a) Print the customer order details into the console.

b) Calculate the order total expense which can calculated as the sum of Order rate (ext_price) and

shipping cost. Then, display the shipping cost and total ordered expense.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote