Calculates a salesperson's pay based on his or her sales. - C++ Data Type

C++ examples for Data Type:float

Description

Calculates a salesperson's pay based on his or her sales.

Demo Code

#include <iostream>
using namespace std;
#include <stdio.h>
int main()//  w ww. j  a  v  a 2s .  co  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;
}

Result


Related Tutorials