Im almost done with this code,, this is what i have to do
Write a program that displays the roman numeral equivalent of any decimal number
between 1 and 20 that the user enters. The roman numerals should be stored in an array of
strings and the decimal number that the user enters should be used to locate the array element holding the roman numeral equivalent. The program should have a loop that allows
the user to continue entering numbers until an end sentinel of 0 is entered.
Input validation: Do not accept scores less than 0 or greater than 20
this is what i got:
// Chapter 8 - Assignment 3, Chips and Salsa
// This program produces a sales report for a salsa maker who
// markets 5 types of salsa. It includes total sales for all
// products and identifies the highest and lowest selling product.
#include<iostream>
#include <iomanip>
using namespace std;
// Function prototypes
int getTotal(int [], int);
int posOfLargest(int [], int);
int posOfSmallest(int [], int);
int main()
{
const int NUM_TYPES = 5;
string name[NUM_TYPES] =
{"mild ", "medium", "sweet ", "hot ", "zesty "};
int sales[NUM_TYPES]; // Holds jars sold for each salsa type
int totalJarsSold,
hiSalesProduct,
loSalesProduct;
for (int type = 0; type < NUM_TYPES; type++)
{
cout << "Jar sold last month of " << name[type] << ": ";
cin >> sales[type];
while (sales[type] < 0)
{ cout << "Jars sold must be 0 or more. Please re-enter: ";
cin >> sales[type];
}
}
// Call functions to get total sales and high and low selling products
totalJarsSold = getTotal(sales, NUM_TYPES);
hiSalesProduct = posOfLargest(sales, NUM_TYPES);
loSalesProduct = posOfSmallest(sales, NUM_TYPES);
// Produce the sales report
cout << endl << endl;
cout << " Salsa Sales Report \n\n";
cout << "Name Jars Sold \n";
cout << "____________________________\n";
/************************************************************
* getTotal *
* Calculates and returns the total of the values stored in *
* the array passed to the function. *
************************************************************/
int getTotal(int array[], int numElts)
{
int total = 0;
for (int pos = 0; pos < numElts; pos++)
total += array[pos];
return total;
}
/************************************************************
* posOfLargest *
* Finds and returns the subscript of the array position *
* holding the largest value in the array passed to the *
* function. *
************************************************************/
int posOfLargest(int array[], int numElts)
{
int indexOfLargest = 0;
/************************************************************
* posOfSmallest *
* Finds and returns the subscript of the array position *
* holding the smallest value in the array passed to the *
* function. *
************************************************************/
int posOfSmallest(int array[], int numElts)
{
int indexOfSmallest = 0;