Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The investment company of Pickum & Loozem has been recording the trading price o

ID: 3832917 • Letter: T

Question

The investment company of Pickum & Loozem has been recording the trading price of a particular stock over a 15-day period. Write a program that queries the user for these prices and stores them in a sequential container. The program must find and display:

a. The trading range (the lowest and highest prices recorded).

b. A sequence that shows how much the price rose or fell each day.

The problem is modified from the description in the text; it is not necessary to sort the data, but standard containers and standard algorithms must be used wherever possible.

All the calculations MUST be done using standard algorithms

Explanation / Answer

executable code:

#include <iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main()
{
int numOfDays;
float posnum = 0;
  

cout<<"How days Sales will be entered? ";
cin>>numOfDays;
float sales[15];
float priceDifference[15];
float minSale, maxSale;


for(int i=0; i<numOfDays; i++)
{
  
cout << "Enter sales of day- " << i+1 <<": $";
cin >> sales[i];

if(i==0)
{
minSale=sales[i];
maxSale=sales[i];
}

else
{

if(sales[i] < minSale)
minSale=sales[i];

if(sales[i] > maxSale)
maxSale=sales[i];
}
}

  
cout<<" The trading range is "<<minSale<<"-"<<maxSale<<endl<<endl;


for(int i=0;i<numOfDays;i++)
{

if(i==0)
{
priceDifference[i]=sales[i];
}
  
else
{
priceDifference[i]=sales[i]-sales[i-1];
}
}
  

for(int i=0;i<numOfDays;i++)
{
  
if(priceDifference[i]<0)
cout<<"In Day-"<<(i+1)<<" the sales fell by $"<<priceDifference[i]<<endl;
  
else
cout<<"In Day-"<<(i+1)<<" the sales rose by $"<<abs(priceDifference[i])<<endl;
}

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote