PDA

View Full Version : C++ Source Help!!



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&#40;int AWeight&#41;;

int main&#40;&#41;
&#123;
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&#58; ";
cin >> weight;

cout << "Do you want a delivery confirmation &#40;y or n&#41;? ";
cin >> delconfirm;

// Invalid Input Messages
if &#40;weight <= 0 || weight >= 16000&#41;
&#123;
cout << "Incorrect weight" << endl;
return 0;
&#125;

if &#40;!&#40;delconfirm == 'y' || delconfirm == 'n'&#41;&#41;
&#123;
cout << "Incorrect value for delivery confirmation" << endl;
return 0;
&#125;

if &#40;weight <= 16 && delconfirm == 'y'&#41;

&#123;
dTotalCharge = 3.45;
&#125;

if &#40;weight <= 16 && delconfirm == 'n'&#41;
&#123;
dTotalCharge = 3.00;
&#125;

if &#40;weight < 16&#41;
dTotalCharge = CompCharge&#40;weight&#41;;

cout << "The Total charge is&#58; " << dTotalCharge << endl;

return 0;

&#125;



double CompCharge&#40;int AWeight&#41;

&#123;
double dTotalCharge;

dTotalCharge = &#40;&#40;AWeight-16&#41;/ 4 * .50 + 3.00 &#41;;

return dTotalCharge;
&#125;

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

Empty_5oul
10-05-2004, 08:31 PM
im afraid i dont know any C++ but some java, if you explain what the ciel function is, i could have a look online about how to use it ??

AMDave
10-06-2004, 11:19 AM
Jeff,

you don't appear to have called the function anywhere in the code snippet that you posted.
Please clarify, where you call it & what the nature of your problem / error message is.

Beerknurd
10-06-2004, 11:05 PM
all japanese to me..... I freaking hate code.....

vaughan
10-06-2004, 11:47 PM
I'm no use at code either but from a practical point of view allow for a user that CAPS LOCK on so if they answer Y or N that these keys are valid too. ie. Do you want a delivery note Y or y / N or n responses are accepted; any other key prompt with "please answer Y or N".