Doesn't Compile correctly

Hello everyone,

I'm working on an assignment I only did a few things. I tried to run the program and it compiles but nothing is displayed. I'm sure I have some errors in my code, but just trying to figure why I can't see anything. I am use code blocks for this assignment.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*Preprocessors*/
#include <iostream> //includes basics
#include <string>
#include <iomanip>
#include <cstdlib>

//Chris Rachal ITP 232 week 2 assignment
/*Prompt the user for the number of days to track the stock. Create an
array of doubles containing the specified number of values to be
entered,
b. Have the user enter the price of the stock for each day. Your code
should not allow the entry of negative prices.
c. Use a function to display all of the stock prices.
d. Using a second function to determine the average price of the stock
for the time period. Display the average with a heading.
e. Using another function, determine the number of days the stock price
differed by more than $2.00 within a 2 day consecutive period.
Display the results.
f. Within another function, change the stored stock price of the last 4
array elements to half of their original value to reflect a stock split.
g. Display the array stock prices reflecting the changes using the
function created in step c.
Use the following guidelines when developing your code:
 Implementation of all your code should be done using pointer notation
except for the initial creation of the array. In other words, no
subscript coding!
 Error checking should be done for negative stock entries.
 Output should be aligned and formatted to 2 decimal places.
 No global variables!
 Include descriptive comments including comments for your functions.
 Use test data to check your numbers.
*****************************************************************************************/
using namespace std;
//Function Prototypes
void inputPrice(double prices[]);


int main()
{

    double prices[7];//array


    void inputPrice();//Calls on the function to get the user to input prices of stock.





    system("pause");

}

//function definitions

//function to get input
void inputPrice(double prices[])
{
    int i;
    double input;
    double *pricesPointer = prices;//our pointer for the array

    cout<<setprecision(2)<<fixed;//two decimal places.






    //loop to input values into the array
    for (int i = 0; i < 7; i++)
    {


        //need to prompt user to enter data
    cout<<"Please enter the price of stock for day "<<i + 1<<":"<<endl;
    cout<<">";
    cin>>input;

    while(input < 0)//validation check to so the user only enters positive numbers.
    {
        cout<<"Please only enter positive numbers."<<endl;
        cout<<">";
        cin>>input;
    }
        *(pricesPointer + i) = input;


    }

        cout<<"Here is what the stock prices look like. "<<input<<endl;

}
/*********************************************************************/

Last edited on
update. I fixed it but I have errors lol
Error messages contain information. Read them and try to understand what they're saying.

Your first issue is that you aren't calling a function.

In main, you should have: inputPrice(prices);
Yeah I'm not very good at programming @Ganado. Thanks for the help.
Don't put yourself down, you're a beginner like everyone else was.
Non-programmers have a Pavlovian response of learned helplessness when it comes to error messages because, ironically, many programs do give useless error messages. But compiler error messages are usually helpful.
But compiler error messages are usually helpful.
^^ once you get a feel for how to read them. I always tell beginners to get it fixed however (including asking for help) and then look at the error message in the context of what you fixed and try to connect the two things, try to see HOW it was telling you to do what you did to fix it. The terminology and such start to make sense after doing that for a little while.
Also, error messages spawn more error messages. Ususally the top 5 or less are meaningful. Fix a couple and recompile, unless you know what to do because you copied the same goof 20 times.
Last edited on
Thanks, I just get so irritated that I don't pick up on it quick enough. I email my teacher a lot lol. I work on my assignment everyday for hours while tending to my kids.
Topic archived. No new replies allowed.