Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please make program... I have no Idea on this.... IMPORTANT INSTRUCTIONS (follow these to avoid losing points NO LATES) Submit your source code files (all

please make program... I have no Idea on this....

IMPORTANT INSTRUCTIONS (follow these to avoid losing points NO LATES)

Submit your source code files (all .h and .cpp files), make sure your name is on each file you submit.

Make sure and use three separate files for your object oriented programs (this means for each program you need to submit three files on Moodle (two .cpp files and 1 .h file). Do not use inline functions. IF YOU VIOLATE THESE RULES points off.

NO GLOBAL VARIABLES no exceptions. Programs with global variables will not be accepted (global constants are fine)

Program 1: Allocate an array dynamically, read from file, sort, and print array Based on Chapter 8 and 9 lecture (20 pts)

Define an integer pointer to use as an array then read from a file. Do the following steps:

Open up a file (prompt the user for the file name)

If you cant open the file, print an error message and exit, else continue

Read in the integers and count them.

Close the file

Allocate an array of integers using that count for the size of the array

Open the file again

Read the numbers into the array and sum them all

Sort them (use bubble sort, code under Files in Moodle)

Print the sorted array and print the average of the values

Use delete to delete the array

Your program should be able to read integers from any file with integers, of course. And example data file would be:

12

19

2

23

53

12

20

37

73

9

111

16

Note: Those using XCode on a Mac, you need to make a project then change the working directory to $PROJECT_DIR/. and you do that by selecting Product/Scheme/Edit Scheme. Then go to the Working Directory part, select Use custom working directory box, then put in the $PROJECT_DIR/. in the box (without the quotes, of course). That will allow selecting data files that are in the same directory as your source code.

Windows users just need to place the data file under the same directory as the source code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions