Cmis 102 Problem Solving And Assessment Answer



I will use sequential, selection, and repetition programming statements and an array to store data.I will define a 2-D array of Float number: Raindata[][] to store the Float values input by the user. To store up to 5 years of monthly data, the array size should be at least 5*12 = 60 elements. In a 2D array this will be RainData[5][12]. We can use #defines to set the number of years and months to eliminate hardcoding values.
A float number (rain) will also be needed to input the individual rain data.A nested for loop can be used to iterate through the array to enter Raindata. A nested for loop can also be used to print the data in the array.A array of strings can be used to store year and month names. This will allow a tabular display with labels for the printout.Functions will be used to separate functionality into smaller work units. Functions for displaying the data and inputting the data will be used.A selection statement will be used to determine if data should be entered.
Answer:
  1. Demonstrate you successfully followed the steps in this lab by preparing screen captures of you running the lab as specified in the Instructions above.

Solution:

Copy the program specified below to the program section in the C compiler

#define NUMMONTHS 12

#define NUMYEARS 5

#include

// function prototypes

void inputdata();

void printdata();

// Global variables

// These are available to all functions

float Raindata[NUMYEARS][NUMMONTHS];

char years[NUMYEARS][5] = {"2011","2012","2013","2014","2015"};

char months[NUMMONTHS][12]

={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

int main ()

    char enterData = 'y';

    printf("Do you want to input Precipatation data? (y for yes)n");

    scanf("%c",&enterData);

    if (enterData == 'y') {

        // Call Function to Input data

        inputdata();

         // Call Function to display data

        printdata();

        printf("No data was input at this timen");

    printf("Please try the Precipitation program again. n");

    return 0;

// function to inputdata

void inputdata() {

     /* variable definition: */

    float Rain=1.0;

    // Input Data

    for (int year=0;year < NUMYEARS; year++) {

        for (int month=0; month< NUMMONTHS; month++) {

            printf("Enter rain for %d, %d:n", year+1, month+1);

            scanf("%f",&Rain);

            Raindata[year][month]=Rain;

n to printdata

void printdata(){

    // Print data

    printf ("yeart montht rainn");

    for (int year=0;year < NUMYEARS; year++) {

        for (int month=0; month< NUMMONTHS; month++) {

            printf("%st %st %5.2fn",

                years[year],months[month],Raindata[year][month]);

Choose input type as text and enter the input data in the text Section

  1. Modify the program to add a function to sum the rainfall for each year. (Hint: you need to sum for each year. You can do this using a looping structure). Support your experimentation with screen captures of executing the new code.

Solution:

Program:

#define NUMMONTHS 12

#define NUMYEARS 5

#include

// function prototypes

void inputdata();

void printdata();

void printsumofrainfall();

// Global variables

// These are available to all functions

float Raindata[NUMYEARS][NUMMONTHS];

char years[NUMYEARS][5] = {"2011","2012","2013","2014","2015"};

char months[NUMMONTHS][12]

={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

int main ()

{

    char enterData = 'y';

    printf("Do you want to input Precipatation data? (y for yes)n");

    scanf("%c",&enterData);

    if (enterData == 'y') {

        // Call Function to Input data

        inputdata();

         // Call Function to display data

        printdata();

        // Call Function to determine the sum of rainfall in each year

        printsumofrainfall();

        printf("No data was input at this timen");

    printf("Please try the Precipitation program again. n");

    return 0;

// function to inputdata

void inputdata() {

     /* variable definition: */

    float Rain=1.0;

    // Input Data

    for (int year=0;year < NUMYEARS; year++) {

        for (int month=0; month< NUMMONTHS; month++) {

            printf("Enter rain for %d, %d:n", year+1, month+1);

            scanf("%f",&Rain);

            Raindata[year][month]=Rain;

// Function to printdata

void printdata(){

    // Print data

    printf ("yeart montht rainn");

    for (int year=0;year < NUMYEARS; year++) {

        for (int month=0; month< NUMMONTHS; month++) {

            printf("%st %st %5.2fn",

                years[year],months[month],Raindata[year][month]);

// Function to printsumofrainfall

void printsumofrainfall(){

    printf("nThe Sum of rainfall for each year is given below:n");

    printf ("yeart sum_of_rainfalln");

    for (int year=0;year < NUMYEARS; year++) {

        float rainfall_sum=0;

        for (int month=0; month< NUMMONTHS; month++) {

            rainfall_sum += Raindata[year][month];

        printf("%st %5.2fn", years[year], rainfall_sum);

  1. Enhance the program to allow the user to enter another meteorological element such as windspeed (e.g. 2.4 mph). Note, the user should be able to enter both rainfall and windspeed in your new implementation. Support your experimentation with screen captures of executing the new code.

Program:

#define NUMMONTHS 12

#define NUMYEARS 5

#include

// function prototypes

void inputdata();

void printdata();

void printaggregatedata();

// Global variables

// These are available to all functions

float Raindata[NUMYEARS][NUMMONTHS];

float Winddata[NUMYEARS][NUMMONTHS];

char years[NUMYEARS][5] = {"2011","2012","2013","2014","2015"};

char months[NUMMONTHS][12] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

    char enterData = 'y';

    printf("Enter data? = n");

    scanf("%c",&enterData);

    if (enterData == 'y') {

        // Call Function to Input data

        inputdata();

         // Call Function to display data

        printdata(

        // Call Function to determine the aggregate in each year

        printaggregatedata();

        printf("No data was input at this timen");

    printf("Please try the Precipitation program again. n");

    return 0;

// function to inputdata

void inputdata() {

     /* variable definition: */

    float Rain=1.0;

    float Wind=1.0;

    // Input Data

    for (int year=0;year < NUMYEARS; year++) {

        for (int month=0; month< NUMMONTHS; month++) {

            printf("Enter rain for %d, %d:n", year+1, month+1);

            scanf("%f",&Rain);

            Raindata[year][month]=Rain;

            printf("Enter wind for %d, %d:n", year+1, month+1);

            scanf("%f",&Wind);

            Winddata[year][month]=Wind;

// Function to printdata

void printdata(){

    // Print data

    printf ("yeart montht raint windn");

    for (int year=0;year < NUMYEARS; year++) {

        for (int month=0; month< NUMMONTHS; month++) {

            printf("%st %st %5.2ft %5.2fn",

                years[year],months[month],Raindata[year][month], Winddata[year][month]);

// Function to printaggregatedata

void printaggregatedata(){

    printf("nThe Sum of rainfall and wind for each year is given below:n");

    printf ("yeart sum_of_rainfallt sum_of_windn");

    for (int year=0;year < NUMYEARS; year++) {

        float rainfall_sum=0;

        float wind_sum=0;

        for (int month=0; month< NUMMONTHS; month++) {

            rainfall_sum += Raindata[year][month];

            wind_sum += Winddata[year][month];

f("%st %5.2fttt %5.2fn", years[year], rainfall_sum, wind_sum);

  1. What happens if you change the NUMMONTHS and NUMYEARS definitions to other values? Be sure to use both lower and higher values. Describe and implement fixes for any issues if errors result. Support your experimentation with screen captures of executing the new code.

Solution:

The lower value for the NUMMONTHS and NUMYEARS definitions is 1. On having the values less than their limit 1, a message is displayed to the user as shown below.

The updated code that takes care of the lower and higher value of number of months and years is given below.

Program:

#define NUMMONTHS 12

#define NUMYEARS 6

#include

// function prototypes

void inputdata();

void printdata();

void printaggregatedata();

// Global variables

// These are available to all functions

float Raindata[NUMYEARS][NUMMONTHS];

float Winddata[NUMYEARS][NUMMONTHS];

char years[NUMYEARS][5] = {"2011","2012","2013","2014","2015"};

char months[NUMMONTHS][12] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

int main ()

    char enterData = 'y';

    printf("Enter data? = n");

    scanf("%c",&enterData);

    if (enterData == 'y')

        if(NUMMONTHS > 0 && NUMYEARS > 0)

            if(NUMMONTHS <=12 && NUMYEARS <= 5)

                // Call Function to Input data

                inputdata();

                // Call Function to display data

                printdata();

                // Call Function to determine the aggregate in each year

                printaggregatedata();

            else {

                printf("The number of years and months can be respectively be atmost 5 and 12 only.n");

void printdata(){

    // Print data

    printf ("yeart montht raint windn");

    for (int year=0;year < NUMYEARS; year++) {

        for (int month=0; month< NUMMONTHS; month++) {

            printf("%st %st %5.2ft %5.2fn",

                years[year],months[month],Raindata[year][month], Winddata[year][month])

// Function to printaggregatedata

void printaggregatedata(){

    printf("nThe Sum of rainfall and wind for each year is given below:n");

    printf ("yeart sum_of_rainfallt sum_of_windn");

    for (int year=0;year < NUMYEARS; year++) {

        float rainfall_sum=0;

        float wind_sum=0;

        for (int month=0; month< NUMMONTHS; month++) {

            rainfall_sum += Raindata[year][month];

            wind_sum += Winddata[year][month];

        printf("%st %5.2fttt %5.2f n", years[year], rainfall_sum, wind_sum);



Buy Cmis 102 Problem Solving And Assessment Answers Online

Talk to our expert to get the help with Cmis 102 Problem Solving And Assessment Answers from Assignment Hippo Experts to complete your assessment on time and boost your grades now

The main aim/motive of the finance assignment help services is to get connect with a greater number of students, and effectively help, and support them in getting completing their assignments the students also get find this a wonderful opportunity where they could effectively learn more about their topics, as the experts also have the best team members with them in which all the members effectively support each other to get complete their diploma assignment help Australia. They complete the assessments of the students in an appropriate manner and deliver them back to the students before the due date of the assignment so that the students could timely submit this, and can score higher marks. The experts of the assignment help services at www.assignmenthippo.com are so much skilled, capable, talented, and experienced in their field and use our best and free Citation Generator and cite your writing assignments, so, for this, they can effectively write the best economics assignment help services.

Get Online Support for Cmis 102 Problem Solving And Assessment Answer Assignment Help Online

Want to order fresh copy of the Sample Cmis 102 Problem Solving And Assessment Answers? online or do you need the old solutions for Sample Cmis 102 Problem Solving And Assessment Answer, contact our customer support or talk to us to get the answers of it.

Assignment Help Australia
Want latest solution of this assignment

Want to order fresh copy of the Cmis 102 Problem Solving And Assessment Answers? online or do you need the old solutions for Sample Cmis 102 Problem Solving And Assessment Answer, contact our customer support or talk to us to get the answers of it.


); }