//declare a 2-d array named numbers int numbers[2][3] = { { 6, 10, 9 }, { 4, 5, 8 } }; for (int row = 0; row < 2; row++)
{
for (int column = 0; column < 3; column++)
{
cout <
}
cout << endl;
}
system("pause");
return 0;
} Pre-Homework 3:
Develop a C++ program that prompts the user to enter a row and a column number, and a special character. The program displays a rectangle with the assigned character.
#include
usingnamespace std; int row, column;
char character;
void display(int r, int c, char s); int main()
{
cout << "Please enter row number: \n";
cin >> row; cout << "Please enter column number: \n";
Write a modular program that accepts up to 20 integer test scores in the range of 0 to
100 from the user and stores them in an array. Then main should report how many perfect scores were entered (i.e., scores of 100), using a value-returning countPerfect function to help it.
int numPerfect = 0; for (int i = 0; i < numElts; i++)
{
if (array[i] >= 90)
numPerfect++;
}
return numPerfect;
}
2. Roman Numeral Converter
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.
// Chapter 8 - Programming Challenge 2, Roman Numeral Converter
// This program displays the roman numeral equivalent of an
// enterered decimal number. The roman numerals are stored in an array.
Write a program that lets a maker of chips and salsa keep track of their sales for five different types of salsa they produce: mild, medium, sweet, hot, and zesty. It should use two parallel five-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. The salsa names should be stored using an initialization list at the time the name array is created. The program should prompt the user to enter the number of jars sold for each type. Once this sales data has been entered, the program should produce a report that displays sales for each salsa type, total sales, and the names of the highest selling and lowest selling products.
// Chapter 8 - Programming Challenge 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. Two parallel
// arrays are used to store the salsa names and quantities sold of each.
#include
#include
#include
usingnamespace std; // Function prototypes
int getSalesData(string [], int []);
int posOfLargest(int []);
int posOfSmallest(int []);
void displayReport(string [], int [], int); constint SIZE = 5; int main()
A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 × 7 array, where each row represents a different monkey and each column represents a different day of the week. The program should first have the user input the data for each monkey. Then it should create a report that includes the following information:
• Average amount of food eaten per day by the whole family of monkeys.
• The least amount of food eaten during the week by any one monkey.
• The greatest amount of food eaten during the week by any one monkey.
// Chapter 8 - Programming Challenge 4, Monkey Business
// This program uses a 2-dimensional array to store data on
// monkey food consumption. The array is passed to functions
// that find total, least, and greatest food consumption.
#include
#include
#include
usingnamespace std; constint NUM_MONKEYS = 3;
constint NUM_DAYS = 7; // Function prototypes
void getData(double[][NUM_DAYS]);
double findGroupTotal(double[][NUM_DAYS]);
double findOneTotal (double[][NUM_DAYS], int);
double findLeastTotal(double[][NUM_DAYS]);
double findGreatestTotal(double[][NUM_DAYS]); int main()
{
// Create a 2-D array to hold the pounds of food consumed
An amateur meteorologist wants to keep track of weather conditions during the past year’s three month summer season and has designated each day as either rainy (‘R’), cloudy (‘C’), or sunny (‘S’). Write a program that stores this information in a 3 × 30 array of characters, where the row indicates the month (0 = June, 1 = July, 2 = August) and the column indicates the day of the month. Note that data is not being collected for the 31st of any month. The program should begin by reading the weather data in from a file. Then it should create a report that displays for each month and for the whole three-month period, how many days were rainy, how many were cloudy, and how many were sunny. It should also report which of the three months had the largest number of rainy days. Data for the program can be found in the RainOrShine.dat file.
// Chapter 8 - Programming Challenge 5, Rain or Shine
// This program creates a weather report for the 3 summer months,
// using data read in from the RainOrShine.dat file located in the
// same directory as this program.. Students must be sure to place
// a copy of this data file in their program project directory.
// TO simplify the program, there are 30 days of data for each month.