|
Quote: days = entries[index].dateTime.Day;
Should have been
++days;
|
|
|
|
|
Not related to your problem, but to the code;
int index = entries.Count(); Why call the count-method, when you're using the .Count-property elsewhere?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
does make that difference ?
|
|
|
|
|
Abdalla Ben Omran wrote: does make that difference ? Calling a property is usually preferred; after assigning that value to it, it gets set to 0 in the loop, overwriting your initial initialization.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
public static TheWeather GetAverageForMonth(List<TheWeather> entries, int year, int month)
{
if (entries == null || entries.Count < 1)
{
return null;
}
int days = 0;
int index = entries.Count();
double total = 0.0;
double Aveg = 0.0;
for (index = 0; index < entries.Count; index++)
{
if (entries[index].dateTime.Year == year
&& entries[index].dateTime.Month == month
&& entries[index].Actual_mean_temp > 0)
{
total += entries[index].Actual_mean_temp;
days += 1;
}
}
Aveg = total / days;
return entries[index];
}
EDIT ==========
Fixed again. Everything was in the first if block, and it shouldn't have been.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 9-May-19 7:29am.
|
|
|
|
|
Surely that should be:
days += 1;
|
|
|
|
|
Or even
days++;
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
or even
days = days + 1;
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Yes it should be, and don't call me Shirley.
Fixed.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Now we wait to see if we got the group-excercise right
..but still, why is there a Linq-call to do a count, if that value is thrown away shortly after?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Shirley the rest of the method shouldn't be grouped within the first if block?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This is what I get fro trying to answer a question right after I get outa bed...
I fixed it again.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
it works very well now Quote: #realJSOP
thanks a lot
|
|
|
|
|
in fact it gives me the wrong answer and the logic its not what i wanted
here what OriginalGriff gave me with his Explantation i have got the right result
thanks anyway then the Explantation of OrginalGriff you can find in comments
average = sum of samples / number of samples
|
|
|
|
|
I had put all the code into the first if block. Try my solution again and see if it works better for you.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
i am going to try and get back to you
|
|
|
|
|
Hi,
I need to detect Advertisement from a video file. I need to understand what library I need to use and proceed.
|
|
|
|
|
I very much doubt if you can: in the same way that adverts are placed between TV show segments with as little intro or extro to the advertisement section as possible so as to make it hard to fast forward recorded programs* any such adverts in a video file would not contain any specific "markers" to make it easy to remove them.
And if someone can up with a good way to identify and automatically remove adverts, you can be absolutely sure that the companies involved in producing and broadcasting content would quickly be altering things to defeat it...
* While we as individuals might wish we could, videos, TV channels, and TV program makers are ultimately funded by adverts and removing them is at best immoral. And at worst illegal since it;s likely that the video content is pirated anyway ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Watch the video, and when you see an ad, say out loud, "I've detected an advertisement".
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
#realJSOP wrote: say out loud, "Alexa, I've detected an advertisement".
FTFY!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
From a very early age, I dreamt of inventing a TV commercial detector so one could skip the commercials. Never figured out the skipping part. (TV used to blink in a corner just before the commercial).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
public static TheWeather GetAverageForMonth(List<TheWeather> entries, int year, int month)
{
TheWeather GetItem = entries.First();
return GetItem;
}
from this method i would like to find the Avergage for EX year 2018, month = 5 which they are already saved in the List <theweather> and the The Class TheWeather has the Properties :
public class TheWeather
{
public DateTime dateTime { get; set; }
public double Actual_mean_temp { get; set; }
public double Record_min_temp { get; set; }
public double Record_max_temp { get; set; }
public double Actual_precipitation { get; set; }
}
without using the LINQ i would like to find the Average please .
|
|
|
|
|
Why without LINQ? And why does your example already contain a LINQ-statement, if you want to avoid it?
using System;
using System.Collections.Generic;
public class Program
{
public class TheWeather
{
public DateTime dateTime { get; set; }
public double Actual_mean_temp { get; set; }
public double Record_min_temp { get; set; }
public double Record_max_temp { get; set; }
public double Actual_precipitation { get; set; }
}
public static TheWeather GetAverageForMonth(List<TheWeather> entries, int year, int month)
{
TheWeather GetItem = entries[0];
return GetItem;
}
public void Main()
{
List<TheWeather> wl = new List<TheWeather>();
wl.Add(new TheWeather() {Actual_mean_temp = 10});
wl.Add(new TheWeather() {Actual_mean_temp = 20});
double sum = 0; int cnt = 0;
for (cnt = 0; cnt < wl.Count ; cnt++)
{
sum += wl[cnt].Actual_mean_temp;
Console.WriteLine(string.Format("item {0}, new avg: {1}", cnt, sum / (cnt + 1)));
}
}
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
i have read the path from a CSV data type then i saved in a list and from this list want to get the average of Temp in month 8 in year 2018 which they have been read and saved in a list
did you get what i want to do ?
with LINQ its always easy to get a solution thus i am trying to use no LINQ just for excerices
|
|
|
|
|
Abdalla Ben Omran wrote: with LINQ its always easy to get a solution thus i am trying to use no LINQ just for excerices Only requires on extra line of code to do as you ask, so yes, good excercise
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|