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

there are acouple codes online, but they don\'t work ( please don\'t copy and pa

ID: 3764929 • Letter: T

Question

there are acouple codes online, but they don't work ( please don't copy and past it here)

C++ only

The sales manager at MyStore wants a program that allows her to enter the company's income and expense amounts, which always will be integers. The number of income and expense amounts may vary each time the program is run. For example, the sales manager may need to enter five income amounts and three expense amounts. Or, she may need to enter 20 income amounts and 30 expense amounts. The program should calculate and display the company's total income, total expenses, and profit (or loss)

Explanation / Answer

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int no_of_income=0;
      int no_of_expense=0;
      int i=0;
      float total_income=0;
      float total_expense=0;
      float profit,loss=0;
cout<<"Enter no of incomes you have"<<endl;
cin>>no_of_income;

   cout<<"Enter no of expenses you have"<<endl;
cin>>no_of_expense;

int* income= (int*)(malloc(sizeof(int)* no_of_income));
int* expense= (int*)(malloc(sizeof(int)* no_of_income));
   cout<<"Enter incomes "<<endl;
   for(i=0;i<no_of_income;i++)

    {
       cin>>income[i];
         }   
                              
cout<<"Enter Expenses "<<endl;
for(i=0;i<no_of_expense;i++)

    {cin>>expense[i];}                         

for(i=0;i<no_of_income;i++)

    { total_income = total_income+income[i];}  
     cout<<"Total income is: "<<total_income<<endl;
  
    for(i=0;i<no_of_expense;i++)

    {total_expense=total_expense+expense[i];}
     cout<<"Total expense is: "<<total_expense<<endl;
   
   if( total_income > total_expense){
   profit= ((total_income-total_expense)/(total_income))*100;
cout<<"Total profit is: "<<profit<<"%"<<endl;
}
    else if( total_income < total_expense){
   loss= ((total_expense-total_income)/(total_income))*100;
    cout<<"Total loss is: "<<loss<<"%"<<endl;
    }
else
cout<<"No profit No loss"<<endl;
  
    system("PAUSE");
    return EXIT_SUCCESS;
}