struct array

May 3, 2017 at 11:40am
Please help me out;

The assignment is about Sales of Traditional Candy from your country for International Food Fair:
Create 2 files using NotePad to read data of 5 types candies/cookies
1- first file keeps name of candies/cookies and its prices per pack.
2 - second file keeps sales of the five candies/cookies (in packs) for Monday, Tuesday and Wednesday 
- First, open the first file, read in the candies and its prices into an array of structures. Close the first file.
- Second, open the second file and read the number of packs sold for the three days of the food fair into the same structured array. Close the second file
- Third step, calculate the total sales in RM for the each type of candy/cookie.
- Fourth step, open an output stream  file and store the name of candies/cookies and the total sales. Close the third file.
May 3, 2017 at 12:08pm
show us what you've done so far and/or mention what are the stumbling blocks to getting started on your own
May 3, 2017 at 1:17pm
#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <cmath>

using namespace std;

struct cookie
{

string cookie_name;
double cookie_price;
int first_sell;
int second_sell;
int thirdz_sell;


};


int main()
{


//now need to read the first file and into this struct.
//then second file
//then need to calculate the total sell within three days.
//then need to write he outstream file inclue cookie name, total sell and so on



//cookie name and price first file:
/*
KitKat 54.88
Jellyt 34.88
Butter 23.89
Snicke 20.78
Twizzl 30.67



seceond file for 3 days sell in packet:

Snickers 3 5 7
Twizzlers 4 6 9
KitKat 7 5 8
Jelly Belly 3 3 2
Butterfinger 2 5 1

*/


// i have three hours left to submit.


Last edited on May 3, 2017 at 1:18pm
May 3, 2017 at 1:30pm
To read files into custom objects here's a recent example: http://www.cplusplus.com/forum/general/214757/#msg999306
May 3, 2017 at 1:35pm
Can you solve it please according to the requirement..?
May 3, 2017 at 1:43pm
Thanks for the offer but I'll let you have the pleasure of doing your own homework
Topic archived. No new replies allowed.