00:01
In this problem, we're asked to create a program that allows the user to enter in the daily sales for a store, and then we return back some information based on these sales.
00:14
So first thing i've done here is create a scanner variable, just called it scan.
00:21
This will allow us to collect user input.
00:25
I also set up the array, so i did an inch array.
00:29
I'm not sure if you're supposed to do an inter -float array, but here's where you would specify the data type.
00:36
If you are supposed to do float, then obviously change it to that.
00:41
But i did an inter -ray, called it sales, and then you set the size here.
00:48
So the size is seven because we're collecting data over a seven -day period.
00:54
And then we want to actually get that data, right? so initialized condens of the ray, and in order to that, we're using a four loop.
01:02
So four ends i equals zero, while i is less than seven i++.
01:08
So for each of these days, right, for each iteration, this four loop, we're going to prompt the user sales for a day, and then we specify the number of the day that we're on here.
01:22
And then they'll enter a number.
01:25
We collect that number using the next int function.
01:28
So we do scan that next int.
01:31
And then we set it equal to the actual spot in the array corresponding to that day, right? so we do that by indexing our arrays, so sales and the square brackets i.
01:47
So why are we doing i plus 1 here? well how i did the four loop was starting at i equals zero and then um saying as long as we're i less than seven but it doesn't really make sense to say day zero so um i just made sure this best why we're doing i plus one here so it'll start on day one and go until seven um so just keep that in mind and then now we're going to find the total sales over the the seven days as well as the average, right? so the total i made a float, and you'll see why in a second, even though if it is an array of ints, then you know, you could make the total an integer variable type, but i'll explain why i made this afloat in a second.
02:42
But regardless, you're going to want to initialize this variable, right? so set equals zero.
02:48
And then we're doing another four loop here...