Jeff
10-05-2004, 07:35 PM
// Program: a3Stagner.cpp
// Determine delivery charges
// Author: Jeff Stagner
// Nickname: AMDUsers.com
// Date: 9/30/04
#include <iostream>
#include <cmath>
using namespace std;
double CompCharge(int AWeight);
int main()
{
const double Delivery_Confirm = 0.45; // Price for delivery confirmation
const double A_Rate = 3.00; // Rate for first pound
const double B_Rate = 0.50; // Rate for each additional 4 ounces
char delconfirm; // delivery confirmation
int weight; // package weight
double dTotalCharge; // Total Charge
// User Inputs
cout << "Please enter the weight of a package in ounces: ";
cin >> weight;
cout << "Do you want a delivery confirmation (y or n)? ";
cin >> delconfirm;
// Invalid Input Messages
if (weight <= 0 || weight >= 16000)
{
cout << "Incorrect weight" << endl;
return 0;
}
if (!(delconfirm == 'y' || delconfirm == 'n'))
{
cout << "Incorrect value for delivery confirmation" << endl;
return 0;
}
if (weight <= 16 && delconfirm == 'y')
{
dTotalCharge = 3.45;
}
if (weight <= 16 && delconfirm == 'n')
{
dTotalCharge = 3.00;
}
if (weight < 16)
dTotalCharge = CompCharge(weight);
cout << "The Total charge is: " << dTotalCharge << endl;
return 0;
}
double CompCharge(int AWeight)
{
double dTotalCharge;
dTotalCharge = ((AWeight-16)/ 4 * .50 + 3.00 );
return dTotalCharge;
}
I am having a problem using the ceil function. Any help would be much appreciated. My assignment is at the link below.
http://www.apsu.edu/lij/04f1010/hw/04f1010a3.html
Thanks, Jeff
// Determine delivery charges
// Author: Jeff Stagner
// Nickname: AMDUsers.com
// Date: 9/30/04
#include <iostream>
#include <cmath>
using namespace std;
double CompCharge(int AWeight);
int main()
{
const double Delivery_Confirm = 0.45; // Price for delivery confirmation
const double A_Rate = 3.00; // Rate for first pound
const double B_Rate = 0.50; // Rate for each additional 4 ounces
char delconfirm; // delivery confirmation
int weight; // package weight
double dTotalCharge; // Total Charge
// User Inputs
cout << "Please enter the weight of a package in ounces: ";
cin >> weight;
cout << "Do you want a delivery confirmation (y or n)? ";
cin >> delconfirm;
// Invalid Input Messages
if (weight <= 0 || weight >= 16000)
{
cout << "Incorrect weight" << endl;
return 0;
}
if (!(delconfirm == 'y' || delconfirm == 'n'))
{
cout << "Incorrect value for delivery confirmation" << endl;
return 0;
}
if (weight <= 16 && delconfirm == 'y')
{
dTotalCharge = 3.45;
}
if (weight <= 16 && delconfirm == 'n')
{
dTotalCharge = 3.00;
}
if (weight < 16)
dTotalCharge = CompCharge(weight);
cout << "The Total charge is: " << dTotalCharge << endl;
return 0;
}
double CompCharge(int AWeight)
{
double dTotalCharge;
dTotalCharge = ((AWeight-16)/ 4 * .50 + 3.00 );
return dTotalCharge;
}
I am having a problem using the ceil function. Any help would be much appreciated. My assignment is at the link below.
http://www.apsu.edu/lij/04f1010/hw/04f1010a3.html
Thanks, Jeff