Thursday, July 8, 2010

const double hourlyRate = 16.78;
const double ssRate = 0.06;
const double fedRate = 0.14;
const double stateRate = 0.05;
const int unionDues = 10;
const int healthInsurance = 35;

// input: hoursWorked, numDependents
// output: grossPay, withholdingamts, netPay

int main()
{
    cout << "....";
    cin >> hoursWorked >> numDependents;

    double grossPay;
    double netPay;
    double ssTax, fedTax, stateTax, health = 0;
    grossPay = (hoursWorked > 40 ? 40 * hourlyRate + (hoursWorked-40)*
            hourlyRate*1.5 : hoursWorked * hourlyRate);

    if (hoursWorked > 40)
        grossPay = 40 * hourlyRate + (hoursWorked-40)*hourlyRate*1.5;
    else
        grossPay =  hoursWorked * hourlyRate;
   
    ssTax = grossPay * ssRate;
    fedTax = grossPay * fedRate;
    stateTax = grossPay * stateRate;

    if (numDependents >= 3)
        health = healthInsurance;

    netPay = grossPay - ssTax - fedTax - stateTax - health;

    cout <<

}

// input: currentPrice, numYears, inflationRate
// output: futureCost
int main()
{
    double currentPrice, inflationRate, futureCost;
    int numYears;
    cout << ...
    cin >> currentPrice >> numYears >> inflationRate;
    inflationRate /= 100;

    futureCost = currentPrice;

   
    for(int i = 0; i < numYears; i++)
        futureCost = futureCost + futureCost * inflationRate;

    cout << futureCost;

}

int main()
{
    cout << "Please enter 10 numbers";
    int n, sumPositive, sumNegative;

    sumPositive = sumNegative = 0;

    for (int i = 1; i <= 10; i++)
    {
        cin >> n;
        if (n > 0)
            sumPositive += n;
        else
            sumNegative += n;
    }
    cout << sumPositive << " " << sumNegative << " " << sumPositive + sumNegative << endl;
}



int main()
{
    cout << ...;
    double n;
    cin >> n;

    // compute sqrt(n)
   
    double guess = n / 2;
    double r;
do
{
    r = n / guess;
    prevGuess = guess;
    guess = (guess + r) / 2;
} while (abs(guess - prevGuess) > 0.01);


}

No comments:

Post a Comment