Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Programming Lanuage: Write a program that computes a business’s potential pr

ID: 3796705 • Letter: C

Question

C++ Programming Lanuage: Write a program that computes a business’s potential profits each year for 20 years using the following assumptions:

1. Gross profit in the first year is projected to be $20,000.

2. Expenses in the first year are expected to be $35,000.

3. Net profit or loss is gross profit minus expenses.

4. Gross profits are expected to increase 10 percent each year.

5. Expenses are expected to increase 4 percent each year. Display the year, the gross profit, the expenses, and the net profit for each year. Also display the year in which a net profit is first reported.

Explanation / Answer

I am sharing the executable C/C++ program to you for the above question.

#include <stdio.h>

int main(void) {
   // your code goes here
  
   //declared Arrays for storing the Projected profits, Expected Expenses and netProfits for 20 years.
   double projectedProfits[20];
   double expectedExpenses[20];
  
   double netProfits[20];
  
   //Initialize the values for the first year with the information given in the question
   projectedProfits[0] = 20000.0;
    expectedExpenses[0] = 35000.0;
    //netprofit = grossProfit - Expenses
    netProfits[0] = projectedProfits[0] - expectedExpenses[0];
  
    int i,j;
  
    //Initialize a flag value to zero to check when the netProfits first rises above zero afterwards
    int flag = 0;
  
    //loop to set all the projected profits and expected expenses for the coming 20 yesrs.
    for(int i = 1; i< 20; i++){
      
        //Gross profit will increase 10% every year
        projectedProfits[i] = projectedProfits[i-1] + (projectedProfits[i-1]*10)/100;
        //Expected Expenses will increase 4% every Year.
        expectedExpenses[i] = expectedExpenses[i-1] + (expectedExpenses[i-1]*4)/100;
        //netprofit = grossProfit - Expenses
        netProfits[i] = projectedProfits[i] - expectedExpenses[i];
        if(netProfits[i] >0 && flag ==0){
            //flag value set to one when the netProfits first rises above zero
            flag = 1;
            printf("Net Profit is first reported in %d year ",i+1);
        }
    }
  
    //Print the Year, Gross Profits , Expected Expenses, Net Profits for all the 20 years.
    for(i = 0; i< 20; i++){
        printf("Year :-   %d , Gross Profit :- %lf , Expenses :- %lf , Net Profit :- %lf ",i+1,projectedProfits[i],expectedExpenses[i],netProfits[i]);
    }
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote