Write a function named scale that takes a struct Rectangle as a parameter and multiplies its length and height properties by an integer multiplier that was also passed in as a parameter. The result of these multiplications should be stored back in the rectangle’s length and height properties. The function should not return a value, but the program that called the function should still see the changes made to the rectangle after the function finishes execution. (5pts)
Design a struct Planet with properties double radius, double mass, and string composition. Outside the struct definition, in main(), create three Planet variables. Make one have radius 12 and mass 70 and composition “H”. Make the 2ndhave radius 1 and mass 1 and composition “H20”. Make the 3rdhave radius 0.66 and the mass 2.72 and the composition “Fe”. Print out the total combined mass of all three planets. (6pts)
If you are loading a file using an ifstream object: ifstream datafile(“data.txt”). Before you loaded the information from the file into your program, on what physical component of the computer was the information in the file stored? (2pts)
pg 1 of 7
Name__________________________ Professor Conroy CSC111 Fall 2021 Final Exam (95pts)
An instructor tells you to add a beginning number and an ending number of a sequence of consecutive numbers and divide the result by two. They then instruct you to multiply by how many numbers were in the sequence. So for instance, if you were given the numbers 51, 52, 53. You would add 51 and 53 to get 104 and divide by 2 to get 52 and you would then multiply 52 by 3 to get 156. Was your performance of this calculation an example of an algorithm, why or why not? (4pts)
Write a function that takes a two dimensional array of integers as a parameter and returns a vector v containing all of the integers from the column whose sum is the largest sum of all of the sums of each of the columns. (10pts)
Write a main program that asks a user their name and then continuously asks the user for positive double values until the user types -1. The program should calculate the average value for the sum of all the doubles and then display it on screen. The program should then wish the user goodbye, mentioning them by name and exit. (8pts)
pg 2 of 7
Name__________________________ Professor Conroy CSC111 Fall 2021 Final Exam (95pts)
Write a program that reads a series of words (one word per line) from a file named data.txt. Each word in the file should have each of its characters shifted by 1 character value in the ASCII table (decremented) and then that new word, with its characters shifted, should be printed to a new file named result.txt. Each word from data.txt should be reprinted with its new encoding in result.txt. Your program should not have any knowledge of how many words are in data.txt or how long the words are or what those words might be. In other words, your program should work for any file composed of a list of words with one per line. (8pts)
Write a function that takes an integer as a parameter and returns a new array of integers that is the size of the value of the parameter passed into the function. Please dynamically allocate the memory for the new array and return the dynamically allocated memory with the appropriate return type for this type of memory. (4pts)
Write a main() function that takes 3 integers as input from the user and stores those values in 3 variables. Print those values to the screen in order from greatest to least. (7pts)
pg 3 of 7
Name__________________________ Professor Conroy CSC111 Fall 2021 Final Exam (95pts)
Write a program that creates two variables, one of type int named, the_answer, and the other a pointer to an int named reference. Set the int variable named the_answer, to 42 and then set the pointer variable to the address of the_answer. Increment the value of the_answer by using only the pointer variable named reference. (4pts)
What is a variable type and why do we have them? (2pts)
What is the difference between a compiler, a preprocessor, and an interpreter? (3pts)
pg 4 of 7
Name__________________________ CSC111 Fall 2021
Professor Conroy Final Exam (95pts)
Design a class Fish (32pts)
The class should have private member variables length, weight, strength, of type double, and a private member variable, species, of type string.
The class should also have a private function:
grow – this function takes two double parameters and each are added to the length and weight properties of the fish object respectively so that the new length of the fish is its original length summed with the first parameter passed in and its new weight is the original weight summed with the second parameter passed in.
The class should also have public methods:
getLength – returns the value of the length attribute
getWeight – returns the value of the weight property
getStrength – returns the value of the strength attribute
getSpecies – returns the value of the species property
eat – this function takes a fish parameter as input and calls the grow function (of the fish doing the eating). The grow function takes 0 for its length parameter but takes the weight value of the fish being eaten for its weight parameter.
swim – this function takes no parameters but returns a double value equal to the strength of the fish divided by the weight of the fish.
The class should have a constructor that takes as a parameter the name of the species and sets the species property to this value. The length property should be set to 2 by default. The weight property should be set to 1 by default, and the strength property should be set to 4 by default.
Your destructor for the class should simply print out “The fish is now gone”
In main() you should create an array of fish named school of size 10. The species of each fish should be: perch, muskee, brook trout, bass, catfish, blue gill, sunny, walleye, salmon, and rainbow trout. The bass should eat both the rainbow trout and the brook trout. You should then write a loop that prints out the species, length, weight, and result of their swim() function.