Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi! I really need help finishing this assignment. I cant seem to attach the exel

ID: 3904776 • Letter: H

Question

Hi! I really need help finishing this assignment. I cant seem to attach the exel file the program should be reading, but if you could point out how to implment the exel file thats going to be read in the final code that would be great! Thanks!

Objectives

Use pointers and arrays

Pass pointers through parameters

Dynamically allocate memory

Read/write to files

Hand-in Requirements

Save your source files in a folder named lastname-firstname-assignment2-4 replacing lastname with your last name and firstname with your first name (all lower-cased). You will have the following code files in your folder:

analyze-real-estate-data.c

analyze-real-estate-data.h

To submit, zip the file and send the zip file with the same naming convention (all lower-cased): lastname-firstname-assignment2-4.tar.gz

Background Information

Your program will read in this file and output the following summary statistics to an output file named analysis.txt

Number of homes sold

Average sales price of homes sold

Number of Residential, Condo, and Multi-Family homes

Average number of bedrooms OR number of bathrooms OR square footage

Process

At the command line, the user will execute the program and pass in the csv file's name:

./analyze-real-estate-data sacramentorealestatetransactions.csv

Make sure the CSV file is in the same folder as your executable. If the file does not exist or the argument is not given, just end the program. After the user hits enter, the summary statistics will appear in both standard output and printed to analysis.txt. The numbers have been removed.

Assignment 2-4 by Firstname Lastname

Number of Sales: XX

Average price of Sales: $XXXXXX.XX

Number of Residential: XX

Number of Condos: XX

Number of Multi Family: XX

Tasks

The program you will write for this assignment has two files: a C source file (.c) and a header file (.h). In the C source file,

Write a main function that processes one command line argument, which is the name of the input CSV file. Only the main function will have printf and fprintf statements.

Write a function that parses the CSV file and provides the counts and averages. This function takes in as parameters: the file pointer and variable pointers which will eventually hold the counts and averages. This function may not have have any printf nor fprintf statements. This function returns nothing.

IMPORTANT: The first row of the CSV file is a header. You will need to skip this row and not include it any counts.

There are definitely better ways in which you can write this program, especially in terms of modularity and reuse. Having all these functionalities in the same function allows us to practice with passing pointers through parameters.

Input Validation

For this assignment, you will need to validate the arguments:

If the first argument command line argument is not available or is not a file that can be opened, end the program. Print out a relevant error message.

Download one of the attached file CSV files. This comma separated values (CSV) file contains the Real Estate transactions in Sacramento, CA between May 7, 2008 and May 15, 2008 (source: https://support.spatialkey.com/spatialkey-sample-csv-data/). There are five versions to work with: the first one is the complete data set while the other four are smaller versions.
Each record (row) contains the following information for each home sold: street, city, zip code, state, number of bedrooms, number of bathrooms, square footage, type of real estate, sale date, price, latitude, and longitude.

Explanation / Answer

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include "parse.h"


void parseCSV(FILE *fp, int *n, double *av, int *nr, int *nc, int *nf){

     char line[100];
     *n = 0;
     double sum = 0;
     *nc = 0;
     *nr = 0;
     *nf = 0;
     fgets((char *)&line, 100,fp);
     while(fgets((char *)&line, 100,fp) != NULL){
          *n++;
           char *ch = strtok(line,",");
           int count = 0;
           while (ch != NULL){
              if (count == 9){
                 sum = sum + atof(ch);
              }
              if (count == 7){
                 if (strcmp(ch,"Residential") == 0)
                   *nr++;
                 if (strcmp(ch,"Condo") == 0)
                   *nc++;
                 if (strcmp(ch,"Multi Family") == 0)
                   *nf++;
              }
           }
         
     }
     *av = sum/(*n);
}

int main(int argc , char *argv[]){

   FILE *fp;
   int n;
   double av;
   int nr;
   int nc;
   int nf;
   if (argc != 2){
      printf("Usage: ./analyze-real-estate-data filename.csv ");
   }
   fp = fopen(argv[1],"r");
   if (fp == NULL){
      printf("Errpr opening file ");
      return 0;
   }
   parseCSV(fp,&n,&av,&nr,&nc,&nf);
   printf("Number of Sales: %d ",n);
   printf("Average price of Sales: %.2f ",av);
   printf("Number of Residential: %.2f ",nr);
   printf("Number of Condos: %.2f ",nc);
   printf("Number of Multi Family: %.2f ",nf);
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote