1 CSCE 1030 Lab 8 General Guidelines: (for ALL of your programming assignments and labs)  Use meaningful variable names.  Use appropriate indentation.  Use comments, especially for the header,...

1 answer below »
I don't have the time today to do these assignments, if there's a way you guys can do the three codes that'd be amazing.


1 CSCE 1030 Lab 8 General Guidelines: (for ALL of your programming assignments and labs)  Use meaningful variable names.  Use appropriate indentation.  Use comments, especially for the header, variables, and blocks of code. Please make sure that your submitted code has comments as points may be deducted for a lack of comments. Example Header: /* Author: Jane Doe ([email protected]) Date: Instructor: Description: A small description in your own words that describe what the program does. Any additional flags needed to allow the program to compile should also be placed here. */ Example Function Header: /* Function: Deposit Parameters: a double representing account balance and a double representing the deposit amount Return: a double representing account balance after the deposit Description: This function computes the account balance after a deposit. */ A. Swapping and Sorting This Problem has two parts—Part I and Part II. Part I: Pass by Reference and Swapping You do not need to submit the code for Part I. Type the following code and run it to understand what it does. mailto:[email protected] 2 Now, move the code that swaps the variables to a user-defined function of void return type to swap them there. Do not move the two cout statements. Make sure your program can actually swap the values. Check if you need to pass by reference. Part II: Sorting Now, you will use the swap function you have written in Part I to sort an array in both ascending and descending orders. You need to submit the code for Part II. Consider the following starter code. 3 Complete the code as follows:  Write a function that swaps the value of two integers. Use your code from Part I for this purpose.  Write a function to sort your array. This function has void return type and takes three parameters—an array that you need to sort, an integer for the size of the array and a Boolean variable with a default value. o When this function is called without any passed value for the Boolean variable, the default value will be used, and the function needs to sort the array in the ascending order. o When this function is called with a value for the Boolean variable as true, and the function needs to sort the array in the ascending order. o When this function is called without a value for the Boolean variable as false, and the function needs to sort the array in the descending order. o Note that this function must call your swap function.  Complete the getarray function to get the actual size of the array from the user, and then get the elements of the array using a loop of your choice.  Complete the function showarray to display the contents of the array using a loop of your choice.  Insert appropriate function calls in the main function to display the array in the correct order. Complete the requested changes, and then save the file as Lab8A.cpp, making sure it compiles and works as expected. Note that you will submit this file to Canvas. 4 B. Multiple Files Start with the provided code and understand what it is doing. Suppose we have a class with 3 students and 5 quiz grades. In the above program, we create a two-dimensional array with 3 rows (one for each student) and 5 columns (one column for each quiz grade). Type up this program as Lab8B.cpp and verify its functionality. Now, make the following changes to your code. 5  The function computeMaximum computes the maximum quiz score out of the 5 scores of each student and stores them in the maximum array. Write this function in a C++ code file named computeMaximum.cpp.  The function showArray displays the content of a one-dimensional array passed to the function. Write this function in a C++ code file named showArray.cpp.  Create a header file called Lab8_Header.h. Move the include and the using namespace statements, as well as function and constant declarations to this file.  Include Lab8_Header.h file in your three .cpp files.  Make sure all files are in the same folder before you compile and test. Complete the requested changes, and then save the file as Lab8B.cpp, making sure it compiles and works as expected. Note that you will submit this file to Canvas. C. File I/O Input data read from the keyboard and output data written to the screen are temporary and will be lost when the program ends. In this lab component, you will learn to read/write from /to a file. The reading from/writing to a file in a program is usually referred to as file I/O (Input/Output). You will use constructs called streams to read from or write data to a file. Streams are among the first examples of objects introduced in this course. An object is a special kind of variable. C++ is an Object Oriented Programming (OOP) language, i.e., it has the ability to handle objects. Before we get started writing the program, create a text file called Data8C.txt that will contain the following integer values, each on a separate line as follows: 236 19 2 917 83 148 7 385 74 Working with files consists of the following four steps: a. Declare the stream variables (don't forget to include library). b. Open the file. c. Process the file (includes reading from and/or writing to the file). d. Close the file. 6 You will then write a complete C++ program called Lab8C.cpp that will read from this file, compute the sum of these integers in the file (reading from the file), and then write the sum of these integers to another file named “Results8C.txt”. This means that (after setting up the proper variables and include directives), you will open the file for reading (what data type will you use for this stream variable?). As for processing the file, since you know in advance how many integers you will be reading in, you can use a for loop to read all of the integer values and keep track of the sum. You do not need to store the numbers, so DO NOT use an array. Use a single integer variable to read in the values. Remember, that instead of using cin, you will use your stream variable that you declared and used to open your files. Outside of the loop, you will then open Results8C.txt file and write the sum • Remember to close both files. • Remember to check if there are issues while opening either file. If there issues, inform the user and terminate the program. Complete the requested changes, and then save the file as Lab8C.cpp, making sure it compiles and works as expected. Note that you will submit this file to Canvas. You should submit the following files:  Lab8A.cpp  Lab8B.cpp  Lab8_Header.h  computeMaximum.cpp  showArray.cpp  Data8C.txt  Lab8C.cpp  Results8C.txt Now that you've finished the lab, use any additional time to practice writing simple programs out of the textbook, lectures, or even ones you come up with on your own to gain some more experience.
Answered Same DayJul 07, 2021

Answer To: 1 CSCE 1030 Lab 8 General Guidelines: (for ALL of your programming assignments and labs)  Use...

Arun Shankar answered on Jul 07 2021
127 Votes
Lab 8C files/Data8C.txt
236
19
2
917
83
148
7
385
74
Lab 8C files/Lab8C.cpp
Lab 8C...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here