CSC1310: LAB 1

$30.00 $24.00

Concepts Structures Header Files Pointers step one: set up your laptop! Make sure your compiler & editor and installed on your laptop by following the document available in ilearn titled “GETTING YOUR COMPUTER SET UP”. STEP TWO: CREATE A COURSE PROGRAM This lab is a review of structures & pointers that you learned in CSC…

Rate this product

You’ll get a: zip file solution

 

Categorys:

Description

Rate this product

Concepts

  • Structures
  • Header Files
  • Pointers

step one: set up your laptop!

Make sure your compiler & editor and installed on your laptop by following the document available in ilearn titled “GETTING YOUR COMPUTER SET UP”.

STEP TWO: CREATE A COURSE PROGRAM

This lab is a review of structures & pointers that you learned in CSC 1300.

You will be building a structure named Course that will hold information about a course at Tennessee Tech.

Then you will implement functions to create a course, destroy (delete) a course, and print a course.

Last, you will implement a driver that will use the Course structure and functions.

Course Structure

Build a structure to contain Course information . The structure tag should be Course and should be defined in Course.h

  • Name (string)
  • Location (string)
  • Sections (pointer to an array of strings)
  • Number of sections (integer)
  • Number of credit hours (integer)

functions

Function prototypes should go in Course.h and function definitions should go in Course.cpp

createCourse function

Purpose:

This is a function that will (dynamically) create a new Course structure variable and then enter the given data into the Course structure members. This function will also have to dynamically create the sections array containing the number of elements as there are sections of the course. Then the function will return the memory address of the Course structure variable from this function.

Function Prototype:

Course* createCourse(string, string, int, int);

Parameters:

  • a string containing the name of the course
  • a string containing the location of the course
  • an integer containing how many sections the course has
  • an integer containing how many credit hours the course has

Returns:

  • a pointer to the Course variable just created with all the given data

DestroyCourse Function

Purpose:

This is a function that will delete (release) both the dynamically created sections array and the course so that there are no memory leaks.

Function Prototype:

void destroyCourse(Course* myCourse);

PrintCourse Function

Purpose:

This function will print all the data in the members of the sent Course structure variable, including all the sections of the course. The data must be printed in a neat easy-to-read format so that the program is user friendly.

Function Prototype:

void printCourse(Course* myCourse);

DRIVER

You are given most of the Driver.cpp code (called Driver_given_lab1.cpp and you will need to copy the contents and place in your Driver.cpp), but you will need to add only FIVE LINES of code in all the places indicated by the comments.

After you add the necessary code, you need to test all the code to make sure you get the same output as below!

The user input is highlighted in yellow.

How many courses are you taking this semester?

3

COURSE NAME: CSC 1300

COURSE LOCATION: CLEM 215

COURSE HOURS: 4

NUMBER OF SECTIONS? 3

SECTION 1: 001

SECTION 2: 002

SECTION 3: 003

***************************************

COURSE NAME: CSC 1310

COURSE LOCATION: FNDH 238

COURSE HOURS: 4

NUMBER OF SECTIONS? 2

SECTION 1: 001

SECTION 2: 002

***************************************

COURSE NAME: CSC 2400

COURSE LOCATION: BRUN 406

COURSE HOURS: 3

NUMBER OF SECTIONS? 3

SECTION 1: 001

SECTION 2: 002

SECTION 3: 003

***************************************

The following are the courses you entered:

*************************************** COURSE 1 ***************************************

COURSE NAME: CSC 1300

COURSE LOCATION: CLEM 215

COURSE HOURS: 4

COURSE SECTIONS:

001

002

003

*************************************** COURSE 2 ***************************************

COURSE NAME: CSC 1310

COURSE LOCATION: FNDH 238

COURSE HOURS: 4

COURSE SECTIONS:

001

002

*************************************** COURSE 3 ***************************************

COURSE NAME: CSC 2400

COURSE LOCATION: BRUN 406

COURSE HOURS: 3

COURSE SECTIONS:

001

002

003

STEP THREE: COMPILE & TEST YOUR PROGRAM

Compile your program:

g++ -Wall –std=c++14 Driver.cpp Course.cpp –o Course

Read more about –Wall here: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

The –std=c++14 option allows compiling in GCC with the C++ version 14 dialect. There are multiple dialects of C++. C++14 is the latest fully supported version of C++. There is also a C++17 and C++2a dialect; both of which are not fully supported or complete.

Run your program:

MAC- ./Course

PC- Course

What to Turn In

Zip all the following files and upload to ilearn.

  • Driver.cpp
  • Course.h
  • Course.cpp
CSC1310: LAB 1
$30.00 $24.00