Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use C# to slove project This exercise is mean to give you practice in writing methods. The methods themselves are fairly simple because the intent

Use C# to slove projectimage text in transcribed

This exercise is mean to give you practice in writing methods. The methods themselves are fairly simple because the intent of the exercise is to build in lots of repetitive exposure to the structure of methods: syntax, header, arguments, returning values, etc. A method is only executed when it is called or invoked. Thus, all methods will then be called from the Main method to test whether the method works. As you are working through the exercise, you may want to first write one method, then scroll down to the Main method, which lists how to test the method and do the segment to test the method. Then scroll back and write the next method and test it. If you write and test methods as a pair as you work your way through the exercise, youll catch errors while writing a method and be able not to repeat the error again.

Rename your class name from Program.cs to Methods.cs Create and complete the following methods in your Methods.cs class. You MUST use the variable and method names that are given to you. You MUST follow the exact sequence of the parameters given to you. Understand what a method is supposed to do before you write it! Important notes: Method are placed inside the class block, under the Main method. o What matters is which block a method is in; however, Main method executes first, so by convention, lets place our methods under the Main method, so that Main

1) Method Name: Product Access modifier: Private Parameters: 2 integers, number1 (required) and number2 (optional, with a default value of 1). Return type: integer Purpose: This method returns the product of two integers In the body of the method block, Declare a variable called result of type integer. Store the product of the two parameters in result. Return the product using the return keyword! remains at the top of the file. Do not put methods inside the Main method! o Methods cannot be nested inside other methods. Use PascalCase when naming methods, not camelCase.

2) Method Name: Product Access modifier: Private Parameters: 3 integers, number1, number2 and number3. Return type: integer Purpose: This method returns the product of the three integers In the body of the method block, Return the product of the three parameters. Use the return keyword!

3) Write a method called CalculateAverage to calculate the average of the first n numbers. The number n should be a parameter of the CalculateAverage method. The method should return the average. Choose an appropriate return type. Use your favorite looping structure and implement counter-controlled repetition. Your loop should maintain a running total of all the numbers from 1 to n. Finally, calculate the average and return it. This method should have no use of ReadLines or WriteLines! Returning means passing the output back to the client or calling method. The output or the return value has nothing to do with showing anything to the user on the Console!

.a file:///GYCIS 340 Spring 2017/Inclass IC10-Overloading-Methods2/Methods/bin/Debug/Methods." [ + Testing Product nethod using 2 The product using two arguments. 5 and 2 is 10 argunents. 5 and 2 Testing Product nethod using 1 argument only. 5* The product using only 1 argunent is Testing Product method using 3 arguments. 2. 3. and 5* he product using three argument - 2. 3. and 5 is 30 Testing Average Method.*** his nethod will calculate the average of all numbers from 1 ton Enter n: 10 he average of all numbers fron 1 to 10 is 5.50

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago