C++ Arithmetic Operator Calculates a salesperson's pay based on sales

Description

C++ Arithmetic Operator Calculates a salesperson's pay based on sales

#include <iostream>
using namespace std;
#include <stdio.h>
int main()// www.  j  a  va 2s .  c o m
{
   char sal_name[20];
   int hours;
   float total_sales, bonus, pay;
   cout << "\n\n";        // Print two blank lines.
   cout << "Payroll Calculation\n";
   cout << "-------------------\n";

   cout << "What is salesperson's last name? ";
   cin >> sal_name;
   cout << "How many hours did the salesperson work? ";
   cin >> hours;
   cout << "What were the total sales? ";
   cin >> total_sales;
   bonus = 0;     // Initially, there is no bonus.

   pay = 4.10 * (float)hours;  // Type casts the hours.

   if (total_sales > 8500.00)
   {
      bonus = 500.00;
   }
   printf("%s made $%.2f \n", sal_name, pay);
   printf("and got a bonus of $%.2f", bonus);
   return 0;
}



PreviousNext

Related