Do you believe in ratings? Either it will be Google, Facebook, Yellow Pages, or YELP. Rating for your business greatly affected by the ratings you receive online. I have made a tool for a client, where any registered customer come and check their cumulative ratings and put expected ratings in the textbox and the small Algo code behind will show them:
How many 5 Stars they need to meet their expected ratings
Here below is the code behind:
Ratings View Model contains following properties
... public double AverageRatings{get; set;} public double ExpectedRatings{get; set;} ...
Below is the method you will call and get the expected numbers of 5 Stars you need to meet your expected ratings as an output.
public int GetTargetRating(RatingsViewModel model) { double avg = model.AverageRatings; double expected = model.ExpectedRatings; if (expected > 4.9) expected = 4.9; double _sum = 0; int count = 1; while ( avg < expected) { avg = model.AverageRatings; for(int i=0; i< count; i++) { _sum += 5.0; } avg = (avg + _sum) / (count+1); count++; _sum = 0; } return count; }
Hope you will find it useful, keep sharing and supporting 🙂
Previous Article
Top 10 Rules For High Standard C# Programming – ASIMplify
Next Article