Xclio 0 Newbie Poster

Problem: Write a C++ program with at least 3 required functions to do the following.

1: Data file contains sales information for the Bilvet manufacturing company. Input data from file and generate a report similar to the one given below. ( Data to be inputted: salespersonID number, productID number, product price(each), discount, quantity ordered, wieght(each) , and distance to customer.

2: Shipping cost is to be calculated using a "value-returning FUNCTION using the table below :(weight and distance both ints)

Weight(lbs) distance(miles) ship cost
w<=25 d > 0 3.00
25<w<=100 d <= 25 5.00
25<w<=100 d > 25 8.00
w>100 d <= 25 12.00
w>100 d > 25 15.00

Weight used in calculations is the total weight of the order.

3: Total Product Cost, Must be calculated using a void FUNCTION which would caluclate and retrn the total product cost in a reference parameter.

4: The Total Cost will be calculated using a "Void" Function which will also calculate and return the sales tax amount of the sale which is 6% of Total Product Cost. Assume no tax on shipping.

Where totalprodcost and shipcost were from pervious function calls and tax and totcost are calculated and returned by the function.

5: Use any method you desire to control the input of data from the file.(check for end-of-file insert counter as first record, insert all zeros for last record, etc) HOWEVER, the method must be consistent so that reading a similar file on another day with more-or-less records, the program will still work without modification.

Data file Is ( Contains only values no column Headings)

1 301 220.75 0.1 5 25 50
2 304 100.99 0.1 1 36 75
3 390 345.75 0.1 4 75 25
2 301 220.75 0.1 3 25 25
4 323 128.20 0.1 3 10 15
5 343 790.27 0.1 2 89 45
4 304 100.99 0.1 1 36 75
4 301 220.75 0.1 4 25 10
6 323 128.20 0.1 1 10 5
6 324 78.00 0.1 9 20 58
5 304 100.99 0.2 12 36 125
1 323 128.2 0.2 7 10 37

I am a Novice Programmer and i'm a bit confused on how to get started with these calculations... So far i have this.

#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>

float calcShipCost(int,int);
void ProdCost(int&,float&,int&);
void calcTotal(float&,float,float,float&);

int main()
{
    int a,b,c,i,j,x,y,z,person,product,quant,weight,distance;
    float price,discount,shipcost,result;
    
    char  salesnames[7][10] = {"Boss","Fred","Bob","Mary","Scott","Susan",
                              "Jack"};
    ifstream inData;
    inData.open("SalesReport.txt");
    
  inData >> person >> product >> price >> discount >> quant >> weight >> 
          distance;
   
   
   for(i=0;i<=6;i++)
  cout << salesnames[i] << endl;
  
   
   
system("pause");
return 0;
}  

float calcShipCost(int weight, int distance)
{     
      float result = 0.00;
      
      if(weight <= 25 && distance > 0)
      {
          result = 3.00;
      }
      else if(weight > 25 && weight <= 100)
      {
           if(distance <=25.00)
             {
                result = 5.00;
             }
           else if(distance > 25.00)
            {
                 result = 8.00;
            }
      }
      else if(weight>100)
      {
           if(distance <= 25)
             { 
                  result = 12.00;
            }
            
           else if(distance > 25)
           {
           result = 15.00;
           }
      }
      return result;
}



/*void ProdCost(int quantity, double price, int discount)
{
    
    
  
   
   return; 
  
}             
void calcTotal(double& totalProdCost, double shipcost, double tax, double& totcost)
{
     
}
*/

I commented out the last 2 calculations because they give me problems and i dont exactly know how to finish this... Please someone help me.. greatly appreciated

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.