Computes video rental amounts and gives appropriate discounts based on the day or customer status. - C++ Operator

C++ examples for Operator:Arithmetic Operator

Description

Computes video rental amounts and gives appropriate discounts based on the day or customer status.

Demo Code

#include <iostream>
using namespace std;
#include <stdio.h>
int main()/*from  w w  w .  ja v  a 2  s .c  o m*/
{
  float tape_charge, discount, rental_amt;
  char first_name[15];
  char last_name[15];
  int num_tapes;
  char val_day, sp_stat;

  tape_charge = 2.00;
  // Before-discount tape fee-per tape.
  // Receive input data.
  cout << "\nWhat is customer's first name? ";
  cin >> first_name;
  cout << "What is customer's last name? ";
  cin >> last_name;
  cout << "\nHow many tapes are being rented? ";
  cin >> num_tapes;
  cout << "Is this a Value day (Y/N)? ";
  cin >> val_day;
  cout << "Is this a Special Status customer (Y/N)? ";
  cin >> sp_stat;
  // Calculate rental amount.
  discount = 0.0;   // Increase discount if they are eligible.
  if ((val_day == 'Y') || (sp_stat == 'Y'))
  {
    discount = 0.5;
    rental_amt = (num_tapes*tape_charge)/(discount*num_tapes);
  }
  // Print the bill.

  cout << "\n\n** Rental Club **\n\n";
  cout << first_name << " " << last_name << " rented " << num_tapes << " tapes\n";

  printf("The total was %.2f\n", rental_amt);
  printf("The discount was %.2f per tape\n", discount);

  if (sp_stat == 'Y')
  {
    cout << "\nThank them for being a Special " << "Status customer\n";
  }
  return 0;
}

Result


Related Tutorials