C language

profileSleepyBear
Lab4IntroSpr21Rec.docx

CSE 1310 – Spring 21

Introduction to Programming

Lab 4 Arrays and Functions

Assigned: Thursday, Apr. 15, 2020

Due: Thursday, Apr. 29, 11:59pm

Purpose:

This Lab 3 assignment is to have you practice writing your own code from the start. You will

· write code using reading input from a file

· write some functions and call them

· use arrays to save data

· use arrays to determine things about the data

Grading

The Lab assignment will be graded out of 100 points. There are multiple parts or tasks that make up each Lab. Each part may have multiple tasks or problems to complete. Each task has a point value associated with it.

Instructions for naming the files that you create for this lab assignment: [Same as Lab 1]

This assignment requires you to create a variety of files and folders: code files (your programs), edited files (your answer document), and a submission folder to store all the documents in that you must submit. Each of these files/folders will be named using a naming convention that makes it easy to distinguish which elements belong to which student. For each of these files/folders the instructions will indicate how to name the item. You will see names like XYZ1234Lab4answers, XYZ1234Lab1Part2, or XYZ1234Lab3.

In each of these names you see "XYZ1234". This is a placeholder for you to put in your initials and the last four digits of your ID number, i.e. "XYZ" gets replaced with your initials and "1234" gets replaced with the last four digits of your UTA ID number. So if I see an instruction that says " Create a NEW C application, i.e. a new C project, called XYZ1234Lab1Part2… " and my initials are JCMT and the last four digits of my ID are 1234, then the file that I should create would be named JCMT1234Lab1Part2. Note that you can use however many initials you have to replace the "XYZ". I use 4 initials so that is what I put; if you use two initials "MW", then replace "XYZ" with "MW". You must use exactly 4 digits from the end of your ID to replace 1234.

Don't change any other part of the given file name. If it says XYZ1234Lab1Part2 and you are ABC and 5678 then your file name must be ABC5678Lab1Part2. It cannot be ABC5678Part2 or ABC567812 or ABC5678LabOnePartTwo etc.

Naming summary: Use your initials and your last 4 digits of ID in place of "XYZ1234" in the given file names. Keep all the rest of the name as defined.

Instructions about the Answers document required for the Lab: [Same as Lab 1]

For every lab assignment you need to create ONE Answers file. In this Answers file you will put in the answers any questions that are asked, you will show the output of code that you write and you will reference any code files that you create for a given question. All answers/outputs etc. go into the same answers document.

· Your answers document needs to be named with your initials and the last four digits of your ID number and then Lab#Answers. So if my initials are JCMT and the last four digits of my ID are 1234, then the answers file for my Lab 4 would be JCMT1234Lab4Answers. [-5 deduction if incorrectly named]

· The ONLY acceptable file formats are Word document (.docx), OpenOffice document(.odt), and PDF (.pdf). {-20 pt deduction if a different but readable format is used. -100 pt deduction if file cannot be read because of the file format.}

· Put your last name, first name and UTA ID in the file on the first line. [-5 deduction if not]

· Label the answers for each question with the number/letter of the question. Separate each answer from the next answer by at least two blank lines. [-5 deduction if not]

· Include EVERY question number/letter combination from the assignment in your answers document. If the question is a coding question telling you to save a file, for example some question numbered 17.b), then in your answers document you should have a line like the following for question 17.b):

17.b) Please see file Lab1Part3.c for this question.”

· Put all your question answers for a lab into the same Answer document for that lab.

· If the lab question asks you to show the output of a doing some particular thing with the code, then you must include a screenshot of the output in the Answer document, i.e. paste in a screenshot picture of the output. For output that takes up more than one screen, make multiple pictures so that every screen is recorded. If you do not include the screenshots in your answer document, then the questions that should have had screenshots will be considered “Not answered” and will be awarded ZERO 0 points.

Each task below will instruct you on what type of "answer" is required for that part of the current problem. If the task says to “Save your program as file XYZ1234Lab1Task1.c” then this .c file should be turned in as part of the assignment and the appropriate reference to the .c file should be put in the answers file as described previously.

Instructions about C files, i.e. the .c documents: [Same as Lab 1]

At the very top of every C file that you create you must put in the following header comment block with the labels shown below for information:

/******************************************************************************

* CSE 1310-005 Spring 2021

* File name:

* Author :

* Created on:

.*

* UTA Student Name:

* UTA ID:

*******************************************************************************/

In this block you will fill in the name of the file that you are creating, the author name (this is the name that you are logged in as), the date that the file was created, your name as UTA records it, and your 10 digit UTA ID number. This block should be before the first #include statement in your code. (Note that you do not have to have an entire line of asterisks at top and bottom. You can have /* on the first line and */ on the last line if desired.)

The IDE you use may have a comment block at the top of your code. You may remove any comment information that is not useful to your assignment. You must put in the labels and information listed above:

Example: As an example, here is a header block that was on one of my files

/******************************************************************************

* File: main.c

* Author: jcmtiernan

* Created on: January 10, 2021, 12:57 PM

.*

* UTA Student Name: Dr. Carter Tiernan

* UTA ID: 1000000000

*******************************************************************************/

#include <stdio.h>

Additonally, you should add a comment block before main, that adds comments to describe your program. Here is an example

/***********

* Lab X Part Y – Testing arithmetic in C

***********/

int main…

Be sure to follow the naming conventions for any code file you create.

There are further instructions at the bottom (after the questions) about how to save the .c files you create in order to be able to turn it in.

Lab 3 Summary of answer document and files prep

1 Create an Answers file named with your initials and the last four digits of your ID number and then Lab#Answers that is of file type .docx, .pdf, or .odt

2 Put lastname, firstname and UTA ID on the first line; then put every question number into the file.

3 Make sure to put an answer or comment after every question number. The answer might be a written answer, a pasted pic or screenshot, or a message indicating that the answer is in an external file.

4 Make sure that when you create your C programs, your program includes the information header comment block shown above including your name. Also make sure you include a comment to describe your specific C program before main. Remove the unneeded default messages and put in your own messages.

5 When using other additional files in your program, plan to include them in your assignment also.

There is info at the bottom about creating a folder for your assignment files to be turned in and submitting the assignment.

Instructions that apply to all lab questions:

A. For later labs, if the instructions say to use code from previous lab/question then everything from previous question should still be in lab except what is explicitly changed in the current question.

B. ** Things not allowed in Dr. Tiernan’s 1310 class in C programs. {More details about these things will be posted in the file “Things Not Allowed”} If you use these elements in your lab assignment C code, you will get a 0 (zero) for the entire question where you used this element.

1) Cannot use exit

2) Cannot use break except between case statements in a switch structure

3) Cannot use continue

4) Cannot use an intentional infinite loop such as while (true)

5) Cannot use goto

Grading Rubric for Lab 4:

Part 1: 45 points

Part 2: 40 points

Part 3: 15 points

Miscellaneous: If you have questions, e-mail Dr. T and/or the TAs through Canvas.

Lab 4 parts to complete:

Part 1: Implement some calculations in code with file input

For this part of the lab, you are going to take some calculations and turn them into a program. You will take input from a file as the inputs for the program and then your program will output the results of the calculations with the user's file inputs.

We had a Snow Week (some have called it Snowmageddon)! And, unfortunately, many folks lost electricity, they lost water, and/or they had broken pipes. You are going to estimate losses associated with some of these various problems.

You are going to come up with estimate losses in Texas for a given set of (imaginary) electricity providers. You will use the given data to find of 1) average hours without electricity per customer for each company, 2) total accrued hours without electricity for each company, 3) percentage of customers who lost power for each company, 4) total customers who lost power for all companies combined, 5) percentage of customers who lost power for all companies combined, and 6) average hours without electricity per customer for all companies combined. In order to calculate these losses you will use the following formulas.

Average of a set of values v1, v2, … vN = (v1 + v2 + v3 +… + vN) / N using floating point

Percentage of some subset out of some total set = subset / total set * 100 using floating point

1 hour = 60 minutes; .5 hours = 30 minutes; .25 hours = 15 minutes; etc.

The input data for the program will be in the input file that is given. [Note: This is not real data. This data is created for the purpose of doing this lab assignment. If you really want to know these pieces of information as relates to the storms, you'll need to do some research on your own.] The data in the file consists of a number of lines of information where each line has the format below. All data on the same line refers to the same company. The data in the file is one word followed by four integers. When reading in this data, do NOT use arrays to store the data. Read in the info into single variables, do the needed calculations, print the appropriate info, then go to the next data in the file, and read it into the same variables replacing the previous data.

company outages customers noPowerCnt avgTimeMin

company = Electricity provider company name

outages = Number of outages for that company

customers = Total number of customers of that company

noPowerCnt = Number of customers without power for any unplanned length of time

avgNoPowerMin = Average length in minutes of an unplanned power outage

Your program should read the input from the file and calculate all of the required information for 1 through 6 above. You should print out the company data in a table as follows:

[NOTE: This spacing is not exact. Use the spacing in the formatted printf given below for the spacing!]

Company Outs NumCust NoPower AvgMin AvgHrs TotHrs Pct

Offcore 3456 1098762 114572 497 8.28 949038.47 10.43%

YellowValley 20 100000 5000 60 1 5000 5%

where Company is company, Outs is outages, NumCust is customers, NoPower is noPowerCnt, AvgMin is avgNoPowerMin, AvgHrs is 1) from above, TotHrs is 2), and Pct is 3). The format for the title line should be:

printf("%16s %6s %10s %9s %6s %6s %10s %6s\n", "Customer", "Outs", "NumCust", "NoPower", "AvgMin", "AvgHrs", "TotHrs", "Pct");

When printing the values for AvgHrs use %6.2lf, for TotHrs use %10.2lf, and for Pct use %6.2lf.

After all company data has been read, calculated and printed, then some overall information and the final three total pieces of information (4 – 6) should be printed out as follows:

The total number of electricity provider companies was : XX

The total number of outages for these XX companies was : YY

The total number of customers who lost power for those XX companies was : ZZ

The percentage of customers who lost power for those XX companies was: AA

The average hours without electricity per customer for those XX companies was: BB

Where the values of XX, YY, ZZ, AA, and BB are:

XX is the number of companies listed in the input file.

YY is the sum of the number of outages for all companies in the file.

ZZ is 4) from above, the sum of the total number of customers who lost power for all companies in the file.

AA is 5), percentage of customers who lost power for all companies combined.

BB is 6), average hours without electricity per customer for all companies combined.

1.a) Write the pseudocode for all the steps needed to implement this program. Remember that you can put the steps into any order that will correctly solve the problem – you do not have the do them in exactly the way they are listed in the problem as long as the order of the output meets the requirements. You may also need some calculations that are not explicitly mentioned but that are required in order to accomplish the task, e.g. what data is needed in order to find the percentage of customers who lost power for all the companies combined and how to do you get that data? {10 pts}

Rubric:

Assessing

10 pts per line max

Exceeds Expectations

10 pts

Meets Expectations

7 - 9 pts

Needs Improvement

5 - 6 pts

Needs Substantial Work 0 – 4 pts

Pts

Pts

*

Wt

Complete-ness {10%}

[weighting = 1}

All steps of the program are accounted for including creation of variables and storing final calculation

Most steps of the program are accounted for including creation of some variables and storing final calculation

Some steps of the program are accounted for. Few variables are created and/or final calculation is not stored

Few steps of the program are accounted for. Variables and/or final calculation missing

Clarity

{8%}

[weighting = .8}

Written description of algorithm is clear and easy to interpret into code in a step by step fashion

Written description of algorithm is mostly clear. Most steps are easy to interpret into code

Written description of algorithm is unclear. Some steps can be interpreted into code

Written description of algorithm is not clear. Few steps can be turned into code

Correctness

{12%}

[weighting = 1.2}

Each step of the algorithm is mathematically correct. Overall formula is correct.

Most steps of algorithm are mathematically correct. Overall formula is mainly correct.

Some steps of algorithm are mathematically incorrect. Overall formula is close but not correct.

Most steps of algorithm are mathematically incorrect. Overall formula is not correct.

Weighted Rubric Total out of 30 points possible

Final score is (Weighted Rubric Total) / 3 to get a score out of 10 points

1.b) Write a C program named XYZ1234Lab4Part1b.c that implements the program you pseudocoded in part 1.a). {20 pts}

Using the pseudocode for the algorithm,

1) Create a new C project with the program header block defined above,

2) In main, create a code framework with comments from pseudocode, then

3) Inside the framework, write code with additional explanatory comments to

a) Get user input for variable values with a meaningful message,

b) Implement the correct formula using the steps given in the pseudocode, and

c) Produce correct output in a meaningful statement,

Requirements:

i) Test, execute, and debug the program with at least three different sets of input

ii) Use good formatting

iii) Use only elements discussed in class by the time the lab is due

iv) Use meaningful variable names (names from formula are OK to use)

v) Do not use shortcut operators

vi) Write all your code yourself (but you may get debugging help from others)

Rubric with coding checklist:

Checklist is completed by the student to record that the element is addressed.

Grading by TA/instructor will assess checkmarks against submitted code to assign points

Code contents and formatting {6 points total}

My C code has the standard class header block comment with :

assignment name, OnlineGDB login name, date, my UTA name, and my UTA ID

My C code uses my pseudocode as framework comments for the program

My code stores the user/file input values into appropriate variables to use

My program implements the steps of the pseudocode as C statements or blocks

The steps of my program use the user's/file input values to execute the formula

The final value of the formula/calculation is stored in a variable before output

I used consistent formatting of braces, indentation, and blank lines

I used meaningful variables names appropriate to the problem being solved

Code correctness, completion, and clarity {11 points total}

My code asks the user for appropriate input values or uses the correct file input

My code accepts input from the user or file for the needed values

The steps of my program correctly implement the formula/calculations

The formula/calculation value is printed in a meaningful output message to the user

The final value of the formula/calculation output by the program is correct

My code runs without any errors or warnings

My code is well-structured, understandable, and straightforward

I did not use shortcut operators (ex. ++, *=)

Coding activity {3 pts total}

I wrote my formula pseudocode myself

I wrote all of my C code myself

I tested my C code with at least three different sets of values

I debugged my code myself and/or I got help from Dr. T, the TAs, my peers, or others

I only used concepts already discussed in the class lectures prior to this due date

Total Part 1.b)

1.c) Screenshots: Using your C code, execute your code with the input values below and show a screenshot of each set of output (one screenshot for each set of input values). Put each input data group into its own file and use that file for input. {Each screenshot is worth 3 points; 15 pts total}

Five short input data files with the data below.

Input data group 1:

Offcore 3456 1098762 114572 497

YellowValley 20 100000 5000 60

UYVEnergy 10 20000 200 10080

SWP&L 0 245987 0 0

RF&D 154 359024 45340 180

Input data group 2:

UnreliantEnergy 1000 223987 94234 2764

PoorOfTexas 251 34726 4434 502

PogostickEnergyLLC 31 7564 2876 612

PaymorePower 12 6502 6498 2160

OctopusEnergy 100 22003 2020 7233

Input data group 3:

SuperNovaElectricCo 34 13400 10876 5762

DeadLeafEnergy 11 7835 954 4441

MyQuestionEnergy 2984 992345 873234 248

LonelySparkleEnergy 23 10943 1354 5897

IberdrolaPotionsLLC 10 35087 7432 127

Input data group 4:

LumiereEnergyLLC 904 3267882 763532 1578

GexaLethargy 45 100435 98342 4320

ExpensivepointEnergySolutionsLLC 87 23667 6978 123

EnergyMonsterLLC 231 92456 52865 877

Dynosaurwatt 63 345612 296134 500

Input data group 5:

ConstellationNoenergyInc 63 98732 83452 634

DimBulbUSLLC 1928 349876 317635 2340

EnemigoEnergy 84 29765 24976 478

NoTexPower&Light 756 908734 745234 1675

EntropyEnergy 102 53423 4329 2564

Part 2: Modify some code and add functionality with arrays and functions

For this part of the lab assignment you are going to use the code you created for Part 1 and modify it to do more tasks. In this lab you will also be writing some different functions and then calling those functions to perform tasks. This code will continue read in data from an input file that you will create but now the data will be stored in arrays.

2.a) In Part 1 you implemented a program to process some data regarding electricity providers. You used single variables to do this work and did not save all of the input data into the program. For this part of the lab, you are now going to save all of the input data into arrays and then use the data in the arrays to do additional tasks.

For Part 2.a) you will be creating three multidimensional arrays to hold the data from the companies. You will put the input data into the arrays as well as the data that is calculated for each company. The three arrays will be compNames, compInts, and compDoubs defined as:

1. compNames - An array of 25 rows of strings, with a max of 40 chars, to hold the company names

2. compInts - An array of 25 rows and 5 columns to hold the integer data items including:

· outages = Number of outages for that company

· customers = Total number of customers of that company

· noPowerCnt = Number of customers without power for any unplanned length of time

· avgNoPowerMin = Average length in minutes of an unplanned power outage

· totNoPowerHrs = total accrued hours without electricity for each company – 2) above

3. compDoubs - An array of 25 rows and 2 columns to hold the floating point data items including:

· avgNoPowerHrs = average hours without electricity per customer for each company – 1)

· pctNoPowerCust = percentage of customers who lost power for each company – 3)

After creating the arrays, your program should read in the data from the file as before and store each data item into the arrays. All data on the same row in the file should go on the same row in each array. The values that are calculated for each company, totNoPowerHrs, avgNoPowerHrs, and pctNoPowerCust, should be calculated after each line is read and stored in the arrays on the same row as the data used to calculate these values. The three calculations done for all companies should NOT be done as in Part 1 while the data is read in. Also in Part 2, you should NOT print the data table as it is read in – you should only read, store, and calculate.

After all the data in the file is read, then call a function, named printElectricityProviders, to print the data table. You should pass in the three arrays to this function. The table should look like the table from Part 1.

After the data table is printed, then call a function, named totProviderData, that will calculate and print the three overall company values (same as Part 1), i.e.

4) total customers who lost power for all companies combined,

5) percentage of customers who lost power for all companies combined, and

6) average hours without electricity per customer for all companies combined.

Make sure that all output data is labeled so that a user would know what is represented by each set of data shown in the output. Make sure that your program runs completely without errors and the correct output is produced. Once your program is working correctly, save your working program as XYZ1234Lab4Part2a.c. [Don’t forget to put a note in your answer file for this question reminding the grader to look for the .c file] {20 points}

Rubric:

Correctly declare required arrays with correct sizes and data types {3 pt}

Correctly read the input values from file and store into array variables {3 pt}

Correctly calculate electricity provider values: totNoPowerHrs, avgNoPowerHrs, pctNoPowerCust and store into arrays correctly {3 pts}

Correctly create the printElectricityProviders function with correct parameters and content {2 pt}

Correctly create the totProviderData function with correct parameters and content {2 pt}

Correctly calculate values in the totProviderData function {3 pt}

Correctly call printElectricityProviders and totProviderData functions with correct parameters. {4 pts}

2.b) Screenshots: Using your C code, execute your code with the input values as described below and show a screenshot of each set of output (one screenshot for each set of input values).

{Each screenshot is worth 3 points; 6 pts total}

Test file 1: Create arrayTestFile1.txt that contains Input data groups 3, 2, and 1 all together, with each grouping remaining in the same order they are given. Include only the lines of data from the three groups and do not include any blank lines.

Test file 2: Create arrayTestFile2.txt that contains Input data groups 4 and 5 all together in the same order they are given

2.c) Write two functions to search the company names array. Both functions should accept the compNames array as their input. One function, findFirst, should find the "first" company name in alphabetical (lexicographical) order and return the row index for the name and the second function, findLast, should find the "last" company name in alphabetical (lexicographical) order and return its index. You'll need to look through the compNames array, use a string compare function, and keep track of the "first" (or "last") name and its location as you go through the array. You should ignore any capitalization of names in your comparison, i.e. compare all strings as lowercase letters only. In the main routine, call findFirst, and then print the company name that was found in a message that explains why that name is printed. Next, call findLast, and then print the company name that was found in a message.

Make sure that all output data is labeled so that a user would know what is represented by each set of data shown in the output. Make sure that your program runs completely without errors and the correct output is produced. Once your program is working correctly, save your working program as XYZ1234Lab4Part2c.c. [Don’t forget to put a note in your answer file for this question reminding the grader to look for the .c file] {12 points}

Rubric:

Correctly create the findFirst function with correct parameters and content {2 pt}

Correctly design and implement the search logic for findFirst to get the correct result {3 pt}

Correctly create the findLast function with correct parameters and content {1 pt}

Correctly design and implement the search logic for findLast to get the correct result {2 pt}

Correctly call findFirst and findLast functions with correct parameters. {2 pts}

Correctly print results from findFirst and findLast functions {2 pts}

2.d) Screenshot: Using your C code from 2.c) , execute your code with the Test file 1 input values from 2.b) and show a screenshot of the output { Screenshot is worth 2 points}

Part 3: Add more functionality with arrays and functions

3.a) Write a function, called companyStats, that takes in the compNames, compInts and compDoubs arrays and then prints out the following information:

1) The company name, number of total customers, noPowerCnt, and pctNoPowerCust for the company with the highest percentage of customers who lost power. This should be in a sentence like the following. (The data below is not the company with the highest percentage.)

"EntropyEnergy, with 53423 customers, had 4329 without power or 8% of its customers."

2) The company name, number of outages, and avgNoPowerHrs for the company with the shortest average time without power. Print this information in a sentence.

3) The company name, number of total customers, and noPowerCnt for the company with the largest sheer number of customers without power. Print this information in a sentence.

Call the function companyStats at the end of the main routine.

Make sure that all output data is labeled so that a user would know what is represented by each set of data shown in the output. Make sure that your program runs completely without errors and the correct output is produced. Once your program is working correctly, save your working program as XYZ1234Lab4Part3a.c. [Don’t forget to put a note in your answer file for this question reminding the grader to look for the .c file] {13 points}

Rubric:

Correctly create the companyStats function with correct parameters and content {2 pts}

Correctly design and implement the search logic for companyStats to get the correct result for:

highest percentage of customers who lost power {2 pts}

shortest average time without power {2 pts}

largest sheer number of customers without power {2 pts}

Correctly print output as specified in the instructions for the three results above {3 pts}

Correctly call companyStats functions with correct parameters. {2 pts}

3.b) Screenshot: Using your C code from 3.a), execute your code with the Test file 1 input values from 2.b) and show a screenshot of the output { Screenshot is worth 2 points}

--------------------------------------------------------------------------------------------------------

Suggestions to help you be successful

A. Pay close attention to all requirements on this page, including file names and submission format. Even in cases where the program works correctly, points will be taken off for not following the instructions given on this page (such as wrong file names, wrong compression format for the submitted code, and so on). The reason is that non-compliance with the instructions makes the grading process significantly (and unnecessarily) more time consuming. Contact the instructor or TA if you have any questions.

B. For each new question that requires you to write code, make a new C project with the exact name that you need to use. Double check that there are no errors before submission. In case of an error in this situation, 0 points will be awarded.

C. Write your code in small steps. Do NOT try to write 25 lines of code and then start trying to run it. Instead, write a small chunk of code - 5 to 10 lines - then save and run those 10 lines to make sure they work and then continue. If the 5 to 10 lines have any errors, start on the errors closest to the top of the file and fix those first. Once you have made changes to fix ONE error, then run the code again to see if that really did fix the error. Don’t go forward until you have fixed to topmost error. If you can’t figure out how to fix that one – try to comment out the line with the error and then fix the remaining errors in your chunk. Don’t go further until you have fixed what you have so far.

D. If you are working on a project and want to start completely over (which is not always the best idea), copy the “old code” that you do not plan to reuse and save it into a text file in a directory with your other materials for the class. You may discover that you do want to reuse that code and if you have saved it, then you won’t have to rewrite all of it.

Instructions about preparing your lab to turn in:

How to prepare your assignment to turn in (or to "submit")

Create a folder for your lab in your CSE 1310 class directory on YOUR computer and name the lab folder with your initials, your last 4 digits, and LabX. [If you don’t have your files organized into folders, I STRONGLY suggest that you start doing this. This is a way to sort the material you keep on your computer and be able to find it later. Check the internet for suggestions on how to do this type of organization.)

As an example, if your name is Happy Camper 1010101010, then your Lab 1 folder name is HXC1010Lab1. Save your HXC1010Lab1answers file in this folder. Next save all the .c files from OnlineGDB for the assignment in the folder. Below is how to do that. Once you have put all the needed .c files in your folder, zip the folder to compress it before submitting it (see info further down with submission details).

Saving .c files out of the IDE (OnlineGDB) [There are two different ways to save the .c files]

First method – downloading the Project file and then unzipping the files from the project folder

To download your C code from OnlineGDB you should go to My Projects and then, for the project you need to download, use the download button under the Actions label. When you click the button, you'll get a typical download window. Save the .zip file that is downloaded into the folder that you plan to submit and name the project folder something useful so you remember what it is. Once the file is downloaded, it will be a zipped (compressed) file like LabX.zip . Once it is in your directory, click on it and UNZIP the file contents. You may need to select how to uncompress the files from the .zip archive. After you unzip the file, you should see the .zip file and the contents that have been uncompressed. You need to keep the .c files that are unzipped (and any text files that might have been created or used) and you need to delete the zip file that was downloaded from OnlineGDB. Rename the main.c file to the appropriate name for the lab part you are working on and then delete the .zip file.

Second method – downloading the files one by one from OnlineGDB

Go to the Project (the program) in OnlineGDB that you want to save and open it. Make sure the program is open in the main window and is the program you are looking at. For example, if you are saving the main.c file for Lab1Part5 you will see the main.c file will say Lab1Part5 in the comments. Make sure your cursor clicks in the editing window of that file. Along the top of the editing window you will see a light blue download arrow. Click the arrow to download just the code in the window you are looking at. For programs that only have one main.c file (and no other text files) this method works fine. Save the .c file into the folder that you plan to submit and name the .c file to the appropriate name for the lab part you are working on. Don't forget to save the .c file in OnlineGDB into your My Projects directory so you can reuse it later if needed.

Reopening projects: If you have closed a project in OnlineGDB and want to go back to it to edit it some more, you can go to the project by going to the My Projects link on the left menu of the window. Then select the folder of the project you want. Open the folder and then select the name of the main.c or other source file you want, then click on the that file. This will open the program again in the editing window for you to keep working on.

C FILE NOTE: Only the .c files, the answers file, and any input or output files that you create should be included in your zipped folder. Do NOT include the entire OnlineGDB project. You will be penalized if you save the project instead of just the .c files and the input and output files.

Because C names all of the main files as main.c, you will need to RENAME each .c file to the correct file name as noted in the instructions for each question. Thus, if you are turning in Lab 3 with two parts that both have one .c file, then you should have a XYZ1234Lab3 folder and inside that folder you should have files for Parts 1 and 2, i.e. a XYZ1234Lab3Part1.c, a answers document, and a XYZ1234Lab1Part2.c file.

How to submit [Same as Lab 2]

The assignment should be submitted via Canvas. Submit a ZIPPED directory/folder called XYZ1234Lab1.zip. The file must be ZIPped (not RAR). No other forms of compression accepted. (Contact the instructor or TA if you do not know how to produce .zip files). The zipped directory should contain your answers document and all the C code files (task1.c etc).

To create a zipped directory called XYZ1234Lab1.zip, follow these steps:

1. Create a folder called XYZ1234Lab1. {This should be the same folder you created already that has your files in it.)

2. If not already done, copy to that folder all your solutions (your answers file, all your C files, and any .txt files that were required for input or output).

3. Zip that folder. On some Windows systems, you can zip a folder by right-clicking on the folder, and then selecting Send to->Compressed (zipped) folder. On Mac, go to the parent directory of your Lab# directory in a Finder window, click on your XYZ1234Lab# folder, then select Compress from the list of file actions (under the gear icon).

4. Submit your zipped folder through your Canvas account at the lab assignment. You click on the name of the assignment and then it goes to the screen where you can upload your zipped file. (Assignments are only accepted through Canvas.)

5. Check that what you uploaded is exactly what you want by going into Canvas and then downloading the assignment you just uploaded, unzipping the folder, and checking the contents to make sure that everything you want to be there is present.

Submission checklist

• Did you correctly name all the lab submission elements – answer document, .c files, the folder, etc?

• Did you create one answers file with your name and UTA ID in the file, and did you include all your answers to non-programming tasks and references to the code files as needed?

· Did you include all the needed screenshots for output making sure that each screenshot was large enough to be read but small enough to keep the answers document from becoming huge?

• Did you answer all of the questions in the lab assignment and did you create all the required .c program files and text files, if any?

· Do all your .c program files run without errors in OnlineGDB?

· Do all your .c program files run and give correct answers in OnlineGDB?

• Did you put all of the files you created into one folder called XYZ1234Lab# ?

• Did you zip that folder into a file called XYZ1234Lab#.zip?

• Did you upload the zipped file to Canvas before the due date and time?

· Did you check what you uploaded to Canvas to make sure it has the desired material in it?