Question: Complete labs using visual studio. Lab 6-1: Array Basics: Use what you have learned about declaring and initializing arrays to complete the following: 1. Write

Complete labs using visual studio.

Lab 6-1: Array Basics:

Use what you have learned about declaring and initializing arrays to complete the following:

1. Write array declarations for each of the following: a. Six grade point averages. b. Seven last names. c. 10 ages.

2. Declare and initialize arrays that store the following: a. The whole numbers 2, 4, 6, 8, 10 b. The last names Carlson, Matthews, and Cooper c. The prices 15.00, 122.00, and 7.50

3. Write an assignment statement that assigns the value 32 to the first element of the array of integers named customerNumber.

4. An array of ints named numbers is stored at memory location 4000. Where is numbers[1]? Where is numbers[4]?

Here is the BattingAverage.cpp file:

#include  #include  using namespace std; int main() { // Declare a named constant for array size here // Declare array here // Use this integer variable as your loop index int loopIndex; // Use this variable to store the batting average input by user double battingAverage; // Use these variables to store the minimim and maximum values double min, max; // Use these variables to store the total and the average double total, average; // Write a loop to get batting averages from user and assign to array cout << "Enter a batting average: "; cin >> battingAverage; // Assign value to array // Assign the first element in the array to be the minimum and the maximum min = averages[0]; max = averages[0]; // Start out your total with the value of the first element in the array total = averages[0]; // Write a loop here to access array values starting with averages[1] // Within the loop test for minimum and maximum averages. // Also accumulate a total of all averages // Calculate the average of the 10 batting averages // Print the batting averages stored in the averages array // Print the maximum batting average, minimum batting average, and average batting average return 0; } 

Lab 7-1: Opening files and performing file output:

In this lab, you open a file and read input from that file in a prewritten C++ program. The program should read and print the names of flowers and whether they are grown in shade or sun. The data is stored in the input file named flowers.dat.

1. Open the source code file named Flowers.cpp using Notepad or the text editor of your choice.

2. Declare the variables you will need.

3. Write the C++ statements that will open the input file flowers.dat for reading.

4. Write a while loop to read the input until EOF is reached.

5. In the body of the loop, print the name of each flower and where it can be grown (sun or shade).

6. Save this source code file in a directory of your choice, and then make that directory your working directory.

7. Compile the source code file Flowers.cpp.

8. Execute the program.

Here is the flower.cpp file:

// Flowers.cpp - This program reads names of flowers and whether they are grown in shade or sun from an input // file and prints the information to the user's screen. // Input: flowers.dat. // Output: Names of flowers and the words sun or shade. #include  #include  #include  using namespace std; int main() { // Declare variables here // Open input file // Write while loop that reads records from file. fin >> flowerName; // Print flower name fin.close(); return 0; } // End of main function 

Here is the flowers.dat file:

Astilbe

Shade

Marigold

Sun

Begonia

Sun

Primrose

Shade

Cosmos

Sun

Dahlia

Sun

Geranium

Sun

Foxglove

Shade

Trillium

Shade

Pansy

Sun

Petunia

Sun

Daisy

Sun

Aster

Sun

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!