#include

////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
    float Dues;      // dues amount

    // Read the dues.
    std::cout << "Enter dues amount: ";
    std::cin >> Dues;

    // Are the dues paid on time?
    std::cout << "On time? (y/n) ";
    char yn;
    std::cin >> yn;
    bool Overdue;   // true if overdue, false if on time
    Overdue = yn != 'y';
    float AmountDue; // amount to be computed

    // Use conditional operator to compute.
    AmountDue = Overdue ? Dues * 1.10 : Dues;

    // Display the dues amount.
    std::cout << "Amount due: ";
    std::cout << AmountDue;

    return 0;
}


Like it on Facebook, Tweet it or share this article on other bookmarking websites.

No comments