Hi
I am new to this forum so please help me out and forgive me for writing code etc incorrectly.
Basically i need to read a from a file and store it into an array. I am using visual studio 2015. Here is a sample data of the file:
1 2 3 4 5
Girl_with_the_dragon_tatoo Larsson e 9780857054036 15.95 5
The_way_of_kings Sanderson a 9780575102484 16.95 10
Fools_Quest Hobb s 9780007444229 19.95 2
The_Name_Of_the_Wind Rothfuss s 9780575081406 18.55 10
Wheres_Wally Handford s 9781406328899 5.50 0
The first class is as follows (the parent class):
1 2 3 4 5 6 7 8
class Product{
//variabes
string title;
string surname;
string isbn;
double wholesalePrice;
//...followed by appropriate getter and setter methods...
}
Then we have the Stock class which is derived from Product...
1 2 3 4 5 6 7 8
class Stock:public Product{
//extra varaibles
public:
double retailPrice;//there are specific formulas for each type of book to //claculate retail price
char bookFormat;
int stockLevel;
//appropriate functions
}
now i know i can read from a file into an array but how do i say that if the book is audio i.e if the character is 'a' then retail price is this..if hardback the character is 'h' thereforee retail price is this...and so on
Then i need to print out the details as follows in another file:
1 2 3 4 5 6
Audiobooks
##############################################
ISBN Title Retail cost Quantity
4323555235 The way... $23.73 10
43237345453 The ring $15.55 2
etc...
Sorry for not being clear enough i have tried using a for loop to read and store into an array, ive tried creating a setRetailPrice methd that passes in two arguements (wholesalePrice, bookFormat) based on this i used the appropriate formulas to calculate the retial price but all seem to be failing...