SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 4 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 09 Jan 2018 My Price 8.00

monthly rainfall amounts for one year storing

I had gotten help with a C# question the other day. I have another program that Im having issues with. I will attach the code I have so far.

C# Programming

A single class application that allows user to inout monthly rainfall amounts for one year storing the values in an array. Produce a report showing the month name along with the rainfall amount and its variance from the mean. Calculate the average rainfall for the year. 

Here is some code that I was playing around with and attempting to alter. Ive gotten stuck every time I try to change the code. 

......................................................CODE.............................................................

using System.IO;

using System;

 

class Program

{

static void Main(string[] args)

{

string[] month = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

double[] value = new double[12];

double varianceValue = 0.0;

 

Console.WriteLine("*********************************************");

Console.WriteLine("THIS PROGRAM ALLOW YOU ENTER DATAr OF RAINFALLFOR ONE YEAR. A TABLEr DISPLAYED SHOWING THE MONTH WITHr RAINFALL FOR THAT MONTH AND VARIANCEr FROM THE MEAN. CALCULATE TOTALr RAINFALL FOR YEAR.");

Console.WriteLine("*********************************************");

 

//The values are entered here.

for (int i = 0; i {

Console.Write("Enter the rainfall for {0}:",month[i]);

value[i] = Int32.Parse(Console.ReadLine());

}

 

//Find the variance of a number

varianceValue = Math.Round(variance(value), 2);

 

Console.WriteLine("*********************************************r");

//Output the calculated data

for (int i = 0; i {

Console.WriteLine("{0} = {1}",month[i], value[i]);

}

Console.WriteLine("Variance = {0}r", varianceValue);

Console.WriteLine("Total Annual Rainfall = {0}r", getSum(value) );

}

 

//function to find the variance

static double variance(double[] nums)

{

if (nums.Length > 1)

{

// Get the average of the value

double avg = getAverage(nums);

double sumOfSquares = 0.0;

foreach (int num in nums)

{

sumOfSquares += Math.Pow((num - avg), 2.0);

}

return sumOfSquares / (double) (nums.Length - 1);

}

else { return 0.0; }

}

 

// Get the average of our values in the array

static double getAverage(double[] nums)

{

int sum = 0;

if (nums.Length > 1)

{

foreach (int num in nums)

{

sum += num;

}

return sum / (double)nums.Length;

}

else

{

return (double)nums[0];

}

}

 

//getting the sum of the values

static double getSum(double[] nums)

{

int sum = 0;

if (nums.Length > 1)

{

foreach (int num in nums)

{

sum += num;

}

return sum;

}

else

{

return (double)nums[0];

}

}

}

Answers

(5)
Status NEW Posted 09 Jan 2018 12:01 PM My Price 8.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)