#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int const types = 5; //how many types of salsa
int jarsSold [types]; //array to hold sales of salsa
char salsaNames[types][7] = {"Mild", //array to hold salsa names
"Medium",
"Sweet",
"Hot",
"Zesty" };
char answer = 'y'; //declared for loop around program
char highest[7];
char lowest[7];
//Program Description to user
cout << "This program will ask for the total amount of jars sold for the month.\n";
cout << "Then it will compute the total sales and the names of the highest\n";
cout << "selling and the lowest selling products.\n\n";
cout << "Do you want to enter the amount of jars sold? ";
cin >> answer;
while (answer == 'y' || answer == 'Y')
{
int total = 0;
//Input the salsa sales totals
for (int count = 0; count < types; count++)
{
cout << "Enter the total jars sold for type " << salsaNames[count] << ".";
cin >> jarsSold[count];
if (jarsSold[count] < 0)
{
cout << "ERROR:The lowest number you can enter is 0.\n";
cin >> jarsSold[count];
}
}
//Display the type with their sales total.
for ( int count = 0; count < types; count++)
{
cout << salsaNames[count] << " has " << jarsSold[count] << " jars sold for the"
<< " month.\n";
}
//calculate the total amount of jars sold
for (int count =0; count < types; count++)
{
total += jarsSold[count];
}
//Display the total
cout << "The total amount of jars sold for the month is " << total <<".\n";
//Find the product with the highest amount of jars sold
highest = salsaNames[0];
for (int count = 1; count < types; count++)
{
if (salsaNames[count] > highest)
highest = salsaNames[count];
}
//Find the product with the lowest amount of jars sold
lowest = salsaNames[0];
for (int count = 1; count < types; count++)
{
if (salsaNames[count] > lowest)
lowest = salsaNames[count];
}
//Display the product with the lowest and the highest amount of jars sold
cout << "The product who had the highest amount of jars sold is " << highest << ".\n\n";
cout << "The product who had the lowest amount of jars sold is " << lowest << ".\n\n";
cout << "Would you like to enter another months totals?\n";
cout << "Y = Yes and N = No\n";
cin >> answer;
//Programmers Name
cout << "\nWritten By:Rick Klinger\n";
}
return 0;
}
//Find the product with the highest amount of jars soldhighest = salsaNames[0];
for (int count = 1; count < types; count++)
{
if (salsaNames[count] > highest)
highest = salsaNames[count];
}
//Find the product with the lowest amount of jars sold
lowest = salsaNames[0];
for (int count = 1; count < types; count++)
{
if (salsaNames[count] > lowest)
lowest = salsaNames[count];
}
This is the part the is coming up with the error.Says that left hand error must '='1value.Tying to make highest and lowest = a character string.somethings different than a value.(Let me know if i posted it right)

New Topic/Question
Reply
MultiQuote





|