×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Program To Create a Variety of Files and Folders in C Assignment Solutions

June 22, 2024
Dr. Jonathan Wright
Dr. Jonathan
🇯🇵 Japan
C
Dr. Jonathan Wright earned his PhD in Computer Science from Tokyo University in Tokyo, Japan. With 8 years of experience in the industry, he has completed over 800 C programming assignments with outstanding results. Dr. Wright's research focuses on distributed systems and cloud computing, and his wealth of knowledge in these areas allows him to deliver innovative and reliable solutions to programming tasks.
Key Topics
  • Instructions
    • Objective
  • Requirements and Specifications
Tip of the day
Use Python libraries effectively by importing only what you need. For example, if you're working with data, using libraries like pandas and numpy can save time and simplify complex tasks like data manipulation and analysis.
News
In 2024, the Biden-Harris Administration has expanded high-dosage tutoring and extended learning programs to boost academic achievement, helping programming students and others recover from pandemic-related setbacks. These initiatives are funded by federal resources aimed at improving math and literacy skills​

Instructions

Objective

Write a C assignment program to create a variety of files and folders.

Requirements and Specifications

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

Any file that is incorrectly named will receive a 5 point deduction for the whole lab assignment. The total penalty is 5 points no matter how many files are named incorrectly.

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.

Source Code

XYZ1234Lab3Part1a #include #define INPUT_FILENAME "shDataSpr22A.txt" const int superHeroesNumber = 30; const int nameLength = 25; int main(void) { char lastName[superHeroesNumber][nameLength]; char firstName[superHeroesNumber][nameLength]; char superHeroName[superHeroesNumber][nameLength]; char gender[superHeroesNumber]; int publicationYear[superHeroesNumber]; int index; char *tempWord; char line[128]; FILE* input; input = fopen(INPUT_FILENAME, "r"); if (!input) { printf("Input file can not be opened!"); return 0; } while(fgets(line, 128, input)) { printf("%s", line); } printf("\n"); fclose(input); return 0; } XYZ1234Lab3Part1b #include #include #include #define INPUT_FILENAME "shDataSpr22A.txt" const int superHeroesNumber = 30; const int nameLength = 25; int main(void) { char lastName[superHeroesNumber][nameLength]; char firstName[superHeroesNumber][nameLength]; char superHeroName[superHeroesNumber][nameLength]; char gender[superHeroesNumber]; int publicationYear[superHeroesNumber]; int index, i; char *tempWord; char line[128]; FILE* input; input = fopen(INPUT_FILENAME, "r"); if (!input) { printf("Input file can not be opened!"); return 0; } index = 0; while(fgets(line, 128, input)) { char* token = strtok(line, ","); strcpy(lastName[index], token); token = strtok(NULL, ";"); strcpy(firstName[index], token); token = strtok(NULL, " "); gender[index] = token[0]; tempWord = strtok(NULL, " "); token = strtok(NULL, " "); while(atoi(token) == 0) { strcat(tempWord, " "); strcat(tempWord, token); token = strtok(NULL, " "); } strcpy(superHeroName[index], tempWord); publicationYear[index] = atoi(token); index++; }

<code ignore--minify class="code-view"> for (i = 0; i printf("Row %d: %s - %s %s, %c, first published in %d\n", i, superHeroName[i], firstName[i], lastName[i], gender[i], publicationYear[i]); } printf("\n"); fclose(input); return 0; } XYZ1234Lab3Part2 #include #include #include #define INPUT_FILENAME "shDataSpr22A.txt" const int superHeroesNumber = 30; const int nameLength = 25; int getSmallestYear(int year[superHeroesNumber], int size) { int minYear = 3000, i; </code>

for (i = 0; i if (year[i] < minYear ) { minYear = year[i]; } } return minYear; } int main(void) { char lastName[superHeroesNumber][nameLength]; char firstName[superHeroesNumber][nameLength]; char superHeroName[superHeroesNumber][nameLength]; char gender[superHeroesNumber]; int publicationYear[superHeroesNumber]; int index, i, maxYear = 0, minYear, alpha; char *tempWord; char line[128]; FILE* input; input = fopen(INPUT_FILENAME, "r"); if (!input) { printf("Input file can not be opened!"); return 0; } index = 0; while(fgets(line, 128, input)) { char* token = strtok(line, ","); strcpy(lastName[index], token); token = strtok(NULL, ";"); strcpy(firstName[index], token); token = strtok(NULL, " "); gender[index] = token[0]; tempWord = strtok(NULL, " "); token = strtok(NULL, " "); while(atoi(token) == 0) { strcat(tempWord, " "); strcat(tempWord, token); token = strtok(NULL, " "); } strcpy(superHeroName[index], tempWord); publicationYear[index] = atoi(token); index++; }

for (i = 0; i printf("Row %d: %s - %s %s, %c, first published in %d\n", i, superHeroName[i], firstName[i], lastName[i], gender[i], publicationYear[i]); } printf("\n"); fclose(input);

for (i = 0; i if (publicationYear[i] > maxYear) { maxYear = publicationYear[i]; } } printf("The most recent publication year is %d\n", maxYear); minYear = getSmallestYear(publicationYear, index); printf("The earliest publication year is %d\n", minYear); alpha = 0;

for (i = 1; i if (strcmp(superHeroName[alpha], superHeroName[i]) > 0) { alpha = i; } } printf("Alphabetically first superhero name is %s\n", superHeroName[alpha]); return 0; }

Similar Samples

Discover our extensive repository of programming homework samples at ProgrammingHomeworkHelp.com. These examples, spanning various languages like Java, Python, and C++, illustrate our proficiency in solving diverse coding challenges. Each sample is meticulously crafted to provide clarity and insight, serving as a valuable resource for mastering programming concepts. Explore our samples today to see how we can help you excel in your programming assignments.