I'm working on an assignment where we have to calculate shipping costs. For some reason, I am getting an infinite loop upon execution. Can some take a look at this and help me out, I cant determine why.
Code:
#include <iostream> 
#include <iomanip> 
#include <cmath> 
#include <fstream> 
using namespace std; 
const double basic_charge = 12; 
const double Vsurcharge = 5; 
const double Dsurcharge = 4; 
const double Wsurcharge = 2; 
double calculate(double length, double width, double height)
{ 
    double volume; 
    volume = length * width * height; 
    return volume; 
} 
int main () 
{ 
    ifstream inFile; 
    ofstream prt("c:\\lab6a_out.txt"); 
    double length, width, height, x, volume, weight, total, shipping_cost; 
    total = 0; 
    cout << "    Shipping Information\n\n"; 
    cout << "Length Width Height Weight Shipping\n"; 
    cout << "                           Cost\n\n";
    prt << "    Shipping Information\n\n"; 
    prt << "Length Width Height Weight Shipping\n"; 
    prt << "                           Cost\n\n"; 
    inFile.open("pkg6a.dat"); 
        if (!inFile) 
        cout << "Error opening the file\n"; 
    inFile >> length, width = 0, height = 0, weight = 0; 
    while (!inFile.eof())  
    { 
        shipping_cost = basic_charge; 
        volume = calculate (length, width, height); 
        if (volume > 7)  
            shipping_cost += Vsurcharge; 
        if (length > 3 || width > 3 || height > 3) 
            shipping_cost += Dsurcharge; 
        if (weight > 50) 
            shipping_cost += weight * Wsurcharge; 
        total += shipping_cost; 
        cout << setw(6) << right << setprecision(0) << length << setw(6) << right << width << setw(7) << right << height << setw(7) << right; 
        cout << weight << setw(9) << right << setprecision(2) << fixed << shipping_cost << endl;
        prt << setw(6) << right << setprecision(0) << length << setw(6) << right << width << setw(7) << right << height << setw(7) << right; 
        prt << weight << setw(9) << right << setprecision(2) << fixed << shipping_cost << endl; 
        inFile >> length, width, height, weight; 
    } 
    cout << "\nTotal cost: " << total;
    prt << "\nTotal cost: " << total; 
    //cin >> x; 
    return 0; 
} 
 
    