Question
COSC-1436, Lab Assignment 6 Submit your answers to the following questions in a word processing document that is compatible with Microsoft Word. The name of
COSC-1436, Lab Assignment 6
Submit your answers to the following questions in a word processing document that is compatible with Microsoft Word. The name of the file you submit should be XYLab6, where X and Y are your first and last initials.
Questions (50 points):
1. Given an integer array named values that contains 25 elements. Write both a regular for loop, as well as a range-based for loop where each loop displays each of the elements in the array.
2. Given two arrays named numberArray1 and numberArray2 that each have 80 elements, write the code that will copy all the values in numberArray1 to numberArray2.
3. As part of a larger program, you need to write code that will store and display the names and population values for 14 countries. Compose the code necessary to define two arrays that will be used in parallel to store the country names and their populations. Assume that a different part of the larger program is responsible for loading values into the parallel arrays you created. Write code that will display each of the countrys names and their corresponding population values.
4. Is there anything seriously wrong with the following code? If so, explain and provide a remedy.
int SIZE = 25;
double values[SIZE];
for (int i = 1; i < SIZE; i++)
{
values[i] = 0.0;
}
5. Compose a function that accepts an array of integer values as an argument and returns the total of the values in the array.
Programming Exercise (50 points):
Write a C++ console application that allows your user to enter the total rainfall for each of 12 months into an array of doubles. The program should validate user input by guarding against rainfall values that are less than zero. After all 12 entries have been made, the program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest rainfall amounts.
Submit two files. A word processing file with your answers to the five Questions and a compressed file containing your solution to the Programming Exercise. Remember to submit them both at the same time.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started