This is a C program. I want you to convert it to a C++ program. Also provide a screenshot that it is also working. Here is the program to be converted: /* Write a program that will compute and display sales commission of a Sales Representative given as input his total sales. The sales commission is computed as 15% of the total sales. Moreover, a bonus of 1000.00 is given if the computed sales commission exceeds 20,000.00. */ #include #include int main() { float TS,SC,TSC; clrscr(); printf("Enter your Total Sales: Php "); scanf("%f",&TS); SC=TS*0.15; if (SC>20000.00) { printf("For Exceeding Php 20000.00 Sales Commission\nYou are entitled for Php 1000.00 bonus!!!\n\n"); TSC=SC+1000.00; // SC+=1000.00 printf("Your Sales Commission of Php %0.2f with the bonus of Php 1000.00 totals to Php %0.2f\n",SC,TSC); } else printf("The Sales Commission is Php %0.2f\n",SC); getch(); return(0); }
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
This is a C program. I want you to convert it to a C++ program. Also provide a screenshot that it is also working.
Here is the program to be converted:
/* Write a program that will compute and display sales commission of
a Sales Representative given as input his total sales. The sales commission
is computed as 15% of the total sales. Moreover, a bonus of 1000.00 is given
if the computed sales commission exceeds 20,000.00. */
#include <stdio.h>
#include <conio.h>
int main()
{
float TS,SC,TSC;
clrscr();
printf("Enter your Total Sales: Php ");
scanf("%f",&TS);
SC=TS*0.15;
if (SC>20000.00)
{
printf("For Exceeding Php 20000.00 Sales Commission\nYou are entitled for Php 1000.00 bonus!!!\n\n");
TSC=SC+1000.00; // SC+=1000.00
printf("Your Sales Commission of Php %0.2f with the bonus of Php 1000.00 totals to Php %0.2f\n",SC,TSC);
}
else
printf("The Sales Commission is Php %0.2f\n",SC);
getch();
return(0);
}
Step by step
Solved in 3 steps with 2 images