Prints daily, weekly, and monthly sales totals. - C++ Operator

C++ examples for Operator:Arithmetic Operator

Description

Prints daily, weekly, and monthly sales totals.

Demo Code

#include <iostream>
using namespace std;
#include <stdio.h>
int main()/*from w  w w  . j av  a2s. c  o  m*/
{
   float daily=12.34;    // Later, these figures
   float weekly=321.65;  // come from a disk file
   float monthly=12345.67; // instead of being assigned as they are here.
   char ans;
   int day;        // Day value to trigger correct case.
   cout << "Is this the end of the month? (Y/N) ";
   cin >> ans;
   if ((ans=='Y') || (ans=='y'))
   {
      day=6;
   }                          // Month value
   else
   {
      cout << "What day number, 1 through 5 (for Mon-Fri)" << " is it? ";
      cin >> day;
   }
   switch (day)
   {
      case (6): printf("The monthly total is %.2f \n",monthly);
      case (5): printf("The weekly total is %.2f \n",weekly);
      default:  printf("The daily total is %.2f \n", daily);
   }
   return 0;
}

Result


Related Tutorials