Question: 1) Do loop. Write the code to calculate the average of series of numbers that the user enters using a do loop (also generically called

 1) Do loop. Write the code to calculate the average ofseries of numbers that the user enters using a do loop (also

1) Do loop. Write the code to calculate the average of series of numbers that the user enters using a do loop (also generically called a do-while loop). Prompt the user to enter as many numbers as he or she likes, i.e. you do not know in advance how many repetitions you need. Maintain a running total of all numbers using the accumulated total structure. Stop asking for more numbers when the user enters x. Calculate the average of all the numbers entered and print it to the Console. You will need to evaluate if the user entered x or not before you can convert it to an integer (the program will crash if you try converting an x into an integer). So, do not call ReadLine and Convert in the same line and instead break that process down into two lines. Read input first, then using an if statement decide if you want to convert it into a number or if you should instead exit the loop using the break statement.

2) Implement Part (1) using a while loop. Implement identical behavior using the same variables. Those variables will have other previous values in them from part (1), i.e. what we would call garbage (e.g., the values inside the total variable, might be good elsewhere, but theyre not valid now in this situation. Therefore the values are garbage to be thrown out.) Before you reuse any variables, you must always therefore reset or reinitialize them. This means, assign the variables the same values you assigned them at declaration, i.e. set integers to zero again, etc. However, do not declare the variables again. Reuse the existing variables, do not create new ones (typing in the data type means you are trying to declare variables).

3. Create the following triangle pattern using nested for loops. Your code should not have more than 2 Write/WriteLine statements the entire pattern should be created using the logic of nested loops.

4) Create the following triangle pattern using nested for loops.

5) Create an equilateral triangle of 5 levels. Place your triangle towards the center of the screen by inserting extra spaces. In the sample, the top row has 20 spaces preceding the first star.

Use the C# to do this project ,project should like the image

file:///G:/CIS 340 Spring 2017/Inclass/IC5-NestedLoopsPatterns/PrintTriangles/bin/Debug/PrintTrian. HHHMNH

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!