Hello, I am having some difficulty starting this program. It asks for my program to use two parallel 5 - element arrays: an array of strings that holds the five salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type.
And this is what I am starting with..
1 2 3 4 5 6 7 8 9
#include <iostream>
usingnamespace std;
int main()
{
constint SALSA = 5;
int jars[SALSA];
char types[SALSA];
}
I am not sure how to input five different strings into the char array, which is giving me quite the headache to figure out. Please help me out. Thanks
#include <iostream>
#include <iomanip>
usingnamespace std;
int main()
{
constint SALSA = 5; //number of different types of salsa
constint STRING_SIZE = 8; //maximum size of each string
char types[SALSA][STRING_SIZE] = { " mild" , "medium" , "sweet" ,"hot" , "zesty"};
int jars[SALSA],
highest, lowest,
total = 0;
for(int count = 0; count < SALSA; count++)
{
cout << " What is the number of jars sold for " << types[count] << " type salsa? ";
cin >> jars[count];
while(jars[count] < 0)
{
cout << "\n The number of jars sold cannot be less than 0." << endl;
cout << " What is the number of jars sold? ";
cin >> jars[count];
}
total += jars[count];
}
highest = jars[0];
lowest = jars[0];
for(int count = 0; count < SALSA; count++)
{
cout << "\n " << types[count] << " type salsa sold " << jars[count] << " jars." << endl;
if(jars[count] > highest)
{
highest = jars[count];
}
if(jars[count] < lowest)
{
lowest = jars[count];
}
}
cout << "\n The total number of jars sold was " << total << " jars." << endl;
cout << "\n The most jars sold was " << highest << " jars." << endl;
cout << "\n The lowest jars sold was " << lowest << " jars." << endl;
return 0;
}