Rabu, 01 April 2026

C++ From Year 1995 File From "H"

 // Filename: HOTELIF.CPP

  // Determines a hotel price

  #include <iostream.h>

  void main()

  {

    char ans;

    int numNights;

    float rackRate = 67.50;

    float discRate = 57.65;

    float totalCost = 0.0;


    cout << "How many nights did the customer stay? ";

    cin >> numNights;


    cout << "Has the customer stayed here before (Y/N)? ";

    cin >> ans;


    if (ans == 'Y')

      { totalCost = discRate * numNights; }


    if (ans == 'N')

      { totalCost = rackRate * numNights; }


    cout.setf(ios::showpoint);

    cout.setf(ios::fixed);

    cout.precision(2);

    cout << "The total cost is $" << totalCost << endl;


    return;

  }


Tidak ada komentar: