what is preventing the arithmatic from displaying?

(code not restricted to column of text file
my text file:
Monday Tuesday Wednesday Thursday Friday Saturday Sunday
34252 85776 65746 93453 63534 34335 0
78352 23412 89889 88387 48021 89903 0
98098 73495 12489 84895 30583 28423 0
28942 38942 38475 83753 83729 82742 0

my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <fstream>

using namespace std; 
int weightFunction(int, int);
int main(){

 //open input file
 ifstream inFile; 
 inFile.open("Trucks.txt");
 if(!inFile){
             cout<<"Can't open file";
             return 1; 
             } 
             
  //write to file 
 ofstream outFile; 
 outFile.open("TruckFines.txt");
              
 //variables             
 string dayOfWeek[7];
 int truckWeight;  
 int currentWeight, currentDays, currentTruck, currentTruckWeight, result;
 int i, n, d/* day # */,t/* truck #*/, g;
 
 //for loop for inFile 
 for (i = 0; i < 7; i++){
     inFile >> dayOfWeek[i];
     }
 while (inFile){
           for (n = 0; n < 7; n++){
               inFile >> currentDays; 
               }
               }
 //for loop for day 
 for (d = 0; d < 7; d++){
     outFile << "Data for " << dayOfWeek[d]<< ":" << endl; 
     outFile << "Trucks with Fines: " << endl; 
     
 //for loop for trucks    
 for (t = 0; t < truckWeight; t++) {
     currentTruckWeight = truckWeight;

     //function call
     result = weightFunction (d, t); 
     outFile <<  "Truck# " << currentTruck + 1 << "   $" << result << endl;
     
     outFile << "Trucks without fines: " << endl; 
     
     //goes through all trucks 
     for(g = 0; g < truckWeight; g++){
           currentWeight = truckWeight; 
           
            //if current truck is less than or equal to the weight limit
            if(currentWeight <= 80000){
                             outFile << "Truck# " << currentTruck + 1 << endl;; 
                             }
     
     }
     outFile << endl; 
     } 
     }
    system("pause");
    return 0; 
    }

 //function for overweight limit
 int weightFunction(int d, int t){
 
 //variables 
 int currentDay, currentTruck, currentWeight, result; 
 
 //if current truck over limit (limit is 80,000)   
 if (d > 80000){
  result <<((currentWeight - 80000) % 100) * 50; 
} 
  
      return result; 
      }


appreciate any help (: thanks
closed account (S6k9GNh0)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <iostream>
#include <fstream>

using namespace std;

int weightFunction(int, int);

int main()
{

//open input file
    ifstream inFile;
    inFile.open("Trucks.txt");
    if(!inFile)
    {
        cout<<"Can't open file";
        return 1;
    }

    //write to file
    ofstream outFile;
    outFile.open("TruckFines.txt");

//variables
    string dayOfWeek[7];
    int truckWeight;
    int currentWeight, currentDays, currentTruck, currentTruckWeight, result;
    int i, n, d/* day # */,t/* truck #*/, g;

//for loop for inFile
    for (i = 0; i < 7; i++)
    {
        inFile >> dayOfWeek[i];
    }
    while (inFile)
    {
        for (n = 0; n < 7; n++)
        {
            inFile >> currentDays;
        }
    }
//for loop for day
    for (d = 0; d < 7; d++)
    {
        outFile << "Data for " << dayOfWeek[d]<< ":" << endl;
        outFile << "Trucks with Fines: " << endl;

//for loop for trucks
        for (t = 0; t < truckWeight; t++)
        {
            currentTruckWeight = truckWeight;

            //function call
            result = weightFunction (d, t);
            outFile <<  "Truck# " << currentTruck + 1 << "   $" << result << endl;

            outFile << "Trucks without fines: " << endl;

            //goes through all trucks
            for(g = 0; g < truckWeight; g++)
            {
                currentWeight = truckWeight;

                //if current truck is less than or equal to the weight limit
                if(currentWeight <= 80000)
                {
                    outFile << "Truck# " << currentTruck + 1 << endl;;
                }

            }
            outFile << endl;
        }
    }
    getchar();
    return 0;
}

//function for overweight limit
int weightFunction(int d, int t)
{

//variables
    int currentDay, currentTruck, currentWeight, result;

//if current truck over limit (limit is 80,000)
    if (d > 80000)
    {
        result <<((currentWeight - 80000) % 100) * 50;
    }

    return result;
}


This topic doesn't interest me. I just reformatted the code.
Last edited on
closed account (S6k9GNh0)
You didn't parse shit by the way. Not sure what you think you rputting in the variables.
Topic archived. No new replies allowed.