I need this to be done asap. Only use visual studio and need to only use void fu
ID: 3570915 • Letter: I
Question
I need this to be done asap. Only use visual studio and need to only use void functions and for loops and while loops. will give max points. My code is at the bottom, please add to it.
#include <iostream>
#include <fstream>
using namespace std;
void LoadData(double data[], int &count)
{
ifstream fileIn("AAPL.txt");
count = 0;
for (int i = 0; i < 252; i++)
{
fileIn >> data[i];
}
fileIn.close();
}
void FirstFive(double data[], int &count)
{
for(int i = 0; i < 5; i++)
{
cout << "day" << i << "price is" << data[i] << endl;
}
}
void LastFive(double data[], int &count)
{
for(int i = 252; i > 5; i--)//try decrement
{
cout << "day" << i << "price is" << data[i] << endl;
}
}
int main ()
{
double data[1000];
int count = 0;
LoadData();
while (true)
{
cout << endl;
cout << "welcome to the Apple stock analysis program" << endl;
cout << "1- display all" << endl;
cout << "2 - First 5 day stock price" << endl;
cout << "3 - First 5 day stock price" << endl;
cout << "4- largest stock price change" << endl;
cout << "0 - exit" << endl;
cout << "What would you like to do?";
int choice;
cin >> choice;
if (choice == 0)
{
break;
}
if (choice == 1)
{
Report(data, count);//display all
}
if (choice == 2)
{
FirstFive(data, count);
}
if (choice == 3)
{
//last 5 days
}
if (choice == 4)
{
//largest percentage change
}
}
system("PAUSE");
return 0;
}
void Report(double data, int count)
{
for (int i = 0; i < count; i++)
{
cout << "day" << (i+1) << "-" << data << endl;
}
}
Explanation / Answer
#include #include #include #include using namespace std; struct incomeInfo { string id; string name; int hours; double hRate; double regPay = 0; double otPay = 0; }; const int ARRAY_SIZE = 25; incomeInfo income[ARRAY_SIZE]; void getIncome(incomeInfo[], int&); void compute(incomeInfo *, int); void display(incomeInfo[], int); void summary(incomeInfo[], int); void sortArray(incomeInfo[], int); void mostPay(incomeInfo[], int); int main() { incomeInfo income[ARRAY_SIZE]; int count = 0; getIncome(income, count); compute(income, count); display(income, count); summary(income, count); sortArray(income, count); mostPay(income, count); return 0; } void getIncome(incomeInfo income[], int &count) { ifstream inputFile; char line[50]; inputFile.open("Payroll.txt"); if (inputFile.fail()) { cout hRate; ptrI++; } else if (ptrI->hours > 40) { ptrI->regPay = 40 * ptrI->hRate; ptrI->otPay = (ptrI->hours - 40) * (ptrI->hRate + (ptrI->hRate* .5)); ptrI++; } return; } void display(incomeInfo income[], int count) { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.