Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS 215-Spring 2019 Lab 6 Learning Objectives - use of arrays to store and manipulate data General Description Write a program to analyze data on

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

CS 215-Spring 2019 Lab 6 Learning Objectives - use of arrays to store and manipulate data General Description Write a program to analyze data on the daily prices of a corporate stock. Each day, stock prices are recorded every hour for 10 hourly readings. The first hour is 8:00am, the beginning price for the day. The last price is the ending price for the day at 5:00pm. The prices are stored in a text file, one price per line, for 10 lines. The first line of the file contains the stock name and date the readings were taken (strings with no spaces). Example XRX 02/19/2019 32.58 33.60 34.89 31.72 30.16 28.46 30.88 32.17 34.18 34.93 The program first asks the user to enter the name of the input file and opens the file for reading. Should the file fail to open, the program prints an error message with the file name and exits. The program then reads the stock name and date, and then the 10 prices into an array of doubles. It then closes the file Next, the program should print a report of prices read, including the (assumed) time the price reading was taken The program should then find and print the price change for the day (last price minus first price), and the highest, lowest and average prices. Finally, it should find and print the median price for the day. The easiest way to find a median of 10 numbers is to sort the array and calculate the average of the 5th and 6th number: 5 10 15 20 25 30 35 40 45 50 (25 30)/2 27.5 Formatting: Your output should look exactly like the examples below, including all prices are printed beginning with a dollar sign, a precision of 2 digits past the decimal point, and a field width of 7 (so: $-999.99) Hours are printed with a field width of 2 followed by ":00" (99:00) - - All dollar signs and decimal points should line up as shown in the examples. Coding: The code should use a constant for the number of elements in the array. This constant should be used instead of "naked literals!. for (int 1-0; i

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

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions