What else is there?

The best interwebs forum ever!


    HALP People!

    Share

    Admin
    Admin

    Posts : 5
    Join date : 2011-11-03

    HALP People!

    Post  Admin on November 16th 2011, 2:19 pm

    CIS 1110 Fall 2011 Assignment 5 Due 11/17/2011

    OVERVIEW: Write a complete C++ program to do the following:
    The program will read in a set of data (from a data file) into three arrays, representing donations to three charities. The program will print (to an output file) the original data neatly, then it will store the sum of each person's donations and print that information. The program will also find the smallest donation to each charity and its position within the array.


    MAIN PROGRAM DETAILS:

    1. NOTE: The data will be read from a data file (discussed separately).
    The main program will read in a parameter value n. Then main will call a function read3arrays() (details below) to read data into three arrays which the main program will call charity1, charity2, and charity3 (or some other names of your choice).

    2. (All output will be sent to an output file.) The main program will call a function print1array(), sending it charity1 and n. Before the function prints, the main program will print a heading explaining what the function will be printing. The print1array() function (details below) will print the first n elements of the charity1 array.

    The main program will also call the print1array() function for charity2 and charity3.

    3. The main program will call a function makenewarray(), sending it the three arrays and n; there will also be another parameter, another array called sumdonations. The function will store values in the sumdonations array (details below).

    When the function returns control to the main program, the main program will use print1array() one more time to print the values in the new sumdonations array.

    4. The main program will call a function findsmallestandpos(), sending it one array and the size n, plus two reference parameters. Using these two reference parameters, the function will find and "return" two things: the element in the array which is smallest and the position in the array of that element.

    For example, assume that the array holds 4 67 3 107 5 9, with n=6. In one reference parameter, the function will store 3, and in the other reference parameter, the function will store 2, since the smallest value in the array (which is 3) is in position 2 of the array.

    The main program will call this function four times, once for each of the arrays (charity1, charity2, charity3, and sumdonations). Using the two actual parameters which match to the two reference parameters in the function, the main program will print the result of each call with a message, like this (print in main, don't print in the function):

    The smallest element in array … is … this value occurs in position … of the array
    FUNCTION DETAILS:

    The function read3arrays() will read a set of data into three arrays. The function will get four parameters, three arrays and an integer giving the size k of these arrays. Each line of data will contain three values (for example, 5 12 13). The first data value (5) will be read into the first array; the second data value (12) will be read into the second array, and similarly for the third data value (13). Then the function will read the second line of data containing three data values, and so on. Do this for each position in the array: 0, 1, 2, …, k - 1. The function will also print the data values as it reads them in.


    The function print1array() will receive one array, call it nums, and one integer, call it k. -- -- -- -- -- --
    It will print the elements of the nums -- -- -- -- -- --
    array neatly, 6 elements per line, as -- -- -- -- --
    shown to the right (this is showing k = 17
    elements in the array). The numbers should align underneath each other in columns.

    The function makenewarray() will have five parameters. Three of them will be the three original arrays (the three charities), and one will be k. The fifth parameter will be a new array called thesums. The function will store values in this new array, as follows: For each position in the new array (from 0 to k-1), the function will add the values in the other three arrays at that position, then store the sum in the new thesums array.

    For example, for position 0, the function will find the sum of charity1[0], charity2[0], and charity3[0]. If the values in position 0 of the three arrays are 10 , 3, and 1, then the sum of these three values is 14. The function will store this integer in thesums[0]. It will do the same for each position in the thesums array.


    DATA: In the data file, have 16, 17, or 19 groups of 3 data values (so the array size is at least 16 and not a multiple of 6). Make sure the smallest value is not in the same position in two or more arrays, and be sure it is never the first or last in any array.


    OUTPUT: Each part of the output in the output file should be clearly marked, with at least 3-4 blank lines between parts.


    USE OF FILES: Read the data values from an input file which you prepare in advance.
    Send the output to an output file.
    Hand in the program, the output file, and the data file used.


    NOTE: Be sure each function has a good comment that mentions the job of the function and mentions each one of the parameters by name.

      Current date/time is October 23rd 2017, 4:41 am