﻿ C# PROGRAMMING EXERCICES - CSharp Programming - 1537
﻿

# C# PROGRAMMING EXERCICES

I am new to computer programming and learning C# programming at the moment.Please could you help me with those 2 exercises:

1) Rainfall Program

Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. First the program should ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period. Use Methods to solve the problem.

2) Convert Program
Write a program that asks the user to enter a distance in metres. The program will then present the following menu of selection: Use Methods to solve the problem.
1. Convert to kilometres
2. Convert to inches
3. Convert to feet
4. Quit the program

The program will convert the distance to kilometres, inches, or feet, depending on the user’s selection. Here are the specific requirements:
a.) Write a void method named showKilometres, which accepts the number of metres as an argument. The method should display the argument converted to kilometres. Convert the metres to kilometres using the following formula:
kilometres = metres * 0.001
b.) Write a void method named ShowInches, which accepts the number of metres as an argument. The method should display the argument converted to inches. Convert the metres to inches using the following formula:

inches = metres * 39.37
c.) Write a void method named ShowFeet, which accepts the number of metres as an argument. The method should display the argument converted to feet. Convert the metres to feet using the following formula:

feet = metres * 3.281

d.) Write a void method named menu that displays the menu of selection. This method should not accept any arguments.

e.) The program should continue to display the menu until the user enters 4 to quit the program.

f.) The program should not accept negative numbers for the distance in metres.

g.)If the user selects an invalid choice from the menu, the program should display an error message.