This is my code below, I'm having an error. ([Error] cannot convert 'float [6]' to float in assignment.)
I don't know what to do or what to put in profit...
My goal is to put the highest expenses, highest profit, and lowest profit below. but I'm having this kind of error.
#include <iostream>
#include <string>
using namespace std;
int main(){
int month[] = {1,2,3,4,5,6};
float profit;
string monthName;
float sales[6] = {1000, 1500, 2500, 5000, 4000, 1800};
float expenses[6] = {500, 250, 100, 1000, 200, 800};
float totalex=0,totalsale=0,totalprofit;
float highSales=0, highExp=0, highProf=0, lowProf=0;
string highMonth="";
cout << "Company Sales and Expenses For 2020" << endl;
for (int i=0; i <=6; i++ ) {
profit = sales[i]-expenses[i];
totalprofit+=profit;
totalsale+=sales[i];
totalex+=expenses[i];
switch(month[i]) {
case 1: monthName="January"; break;
case 2: monthName="February"; break;
case 3: monthName="March"; break;
case 4: monthName="April"; break;
case 5: monthName="May"; break;
case 6: monthName="June"; break;
}
if(sales[i]>highSales) {
highSales = sales[i];
highMonth = monthName;
highExp = expenses;
highProf = profit;
lowProf = profit;
}
cout <<"\n\n" << monthName<<"\t\t"<<sales[i]<<"\t\t"<<expenses[i]<<"\t\t\t"<<profit;
}
cout << "\nSummary : " << endl;
cout << "\tTotal Sales : " << totalsale << endl;
cout << "\tTotal Expenses : " << totalex << endl;
cout << "\tTotal Profit : " << totalprofit << endl;
cout << "\tHighest Sales : " << highSales << "\tMonth of " << highMonth << endl;
cout << "\tHighest Expenses : " << highExp << "\tMonth of " << highMonth << endl;
cout << "\tHighest Profit : " << highProf << "\tMonth of " << highMonth << endl;
cout << "\tLowest Profit : " << lowProf << "\tMonth of " << highMonth << endl;
cout << "\nProgrammed by: ";
return 0;
}
This is my code above. The problem is that I cant print the highest expenses, highest profit, and lowest profit. I cant compile and run as this error shows [Error] cannot convert 'float [6]' to float in assignment.