Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace populationInEgypt
- {
- class Program
- {
- static void Main(string[] args)
- {
- double[] pop = new double[4];
- for (int i = 0; i < pop.Length; i++)
- {
- Console.Write("enter the population of year 200"+(i+1)+" : ");
- pop[i] = double.Parse(Console.ReadLine());
- Console.WriteLine();
- }
- double rate = 0.0;
- for (int i = 0; i < pop.Length; i++)
- {
- if (i == 0)
- {
- Console.WriteLine("200{0} | {1} | {2} %", i + 1, pop[i], rate);
- }
- else if (i < pop.Length)
- {
- rate = (pop[i] - pop[i-1]) / pop[i-1];
- Console.WriteLine("200{0} | {1} | {2} %", i + 1, pop[i], rate);
- }
- else
- {
- rate = (pop[i + 1] - pop[i]) / pop[i];
- Console.WriteLine("200{0} | {1} | {2} %", i + 1, pop[i], rate);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement