Question

In: Computer Science

Upon completion of this exercise, you will have demonstrated the ability to: Use C# loops Construct...

Upon completion of this exercise, you will have demonstrated the ability to:

  • Use C# loops
  • Construct conditions

INTRODUCTION

Your instructor will assign one of the following projects, each involves the user of loops and the construction of conditions to control them.

CODING STANDARDS

The following coding standards must be followed when developing your program:

  • An opening documentation at the beginning of the source file describing the purpose, input, process, output, author, last modified date of the program.
  • Write only one statement per line.
  • Write only one declaration per line.
  • Use camelCase for local variable names.
  • Use UPPER_CASE for constant variable names.
  • If continuation lines are not indented automatically, indent them one tab stop (four spaces).
  • Do NOT use goto or break statements in your looping structure.

PROJECTS

  1. Write a program that will read a sequence of numbers from the keyboard (you are free to choose the input flow method of your choice), and display the minimum, maximum, average, and range (highest minus lowest) of the entered values. Validate the input.

Solutions

Expert Solution

Code to copy:

   using System;

   class aggreagate
   {
       static void Main()
       {
           //First we take user input for num_arrber of inputs and assign to n after Integer Conversion
           Console.Write("Enter Number Of Inputs: ");
           int n = Convert.ToInt32(Console.ReadLine());
           //We create an integer array of size n
           int[] num_arr = new int[n];
           //We use for loop to take n num_arrbers as input and assign to array
           for(int i = 0; i < n ; i++)
           {
               Console.Write("Enter Number "+(i+1)+" : ");
               num_arr[i] = Convert.ToInt32(Console.ReadLine());
           }
           //Initialising Variables
           int sum_arr = 0, min_arr = num_arr[0], max_arr = num_arr[0];
           //We again use for loop to go through values to fond sum_arr, min_arr and max_arr
           for(int i = 0; i < n ; i++)
           {
               if(num_arr[i] < min_arr)
               {
                   min_arr = num_arr[i];  
               }
               if(num_arr[i] > max_arr)  
               {
                   max_arr = num_arr[i];  
               }
               sum_arr = sum_arr + num_arr[i];
           }
           //Calculating Range and Average
           double avg = (1.0 * sum_arr)/n;
           int range = max_arr - min_arr;
           //Printing results
           Console.WriteLine("Minimum: "+min_arr);
           Console.WriteLine("Maximum: "+max_arr);
           Console.WriteLine("Average: "+avg);
           Console.WriteLine("Range: "+range);
       }
   }

Code Screenshot:

Output Screenshot:


Related Solutions

OBJECTIVE Upon completion of this exercise, you will have demonstrated the ability to: Use C# loops...
OBJECTIVE Upon completion of this exercise, you will have demonstrated the ability to: Use C# loops Construct conditions INTRODUCTION Your instructor will assign one of the following projects, each involves the user of loops and the construction of conditions to control them. CODING STANDARDS The following coding standards must be followed when developing your program: An opening documentation at the beginning of the source file describing the purpose, input, process, output, author, last modified date of the program. Write only...
Objective: Upon completion of this program, you should gain experience with overloading basic operators for use...
Objective: Upon completion of this program, you should gain experience with overloading basic operators for use with a C++ class. The code for this assignment should be portable -- make sure you test with g++ on linprog.cs.fsu.edu before you submit. Task Create a class called Mixed. Objects of type Mixed will store and manage rational numbers in a mixed number format (integer part and a fraction part). The class, along with the required operator overloads, should be written in the...
This exercise will test your ability to use the basic instance methods of String. The exercise...
This exercise will test your ability to use the basic instance methods of String. The exercise is to create a program that compares two Strings ignoring the case and returns the offset between the first two distinct characters in the two Strings from left to right. All the input strings have five characters. For this exercise, compareToIgnoreCase() and compareTo() methods are not allowed. Example 1, "London" and "Lately" will return the offset between 'o' and 'a', which is 14 Example...
Upon successful completion of the MBA program, imagine you work in the analytics department for a...
Upon successful completion of the MBA program, imagine you work in the analytics department for a consulting company. Your assignment is to analyze the following databases: Hospital Provide a detailed, four part, statistical report with the following sections: Part 1 - Preliminary Analysis Part 2 - Examination of Descriptive Statistics Part 3 - Examination of Inferential Statistics Part 4 - Conclusion/Recommendations Part 1 - Preliminary Analysis Generally, as a statistics consultant, you will be given a problem and data. At...
What are pre-test loops. Which C++ statements use pre-test loops? Why pre-test loops are called 0...
What are pre-test loops. Which C++ statements use pre-test loops? Why pre-test loops are called 0 to N loops? When do you use the pre-test loops? Give at least one example.
Language: C++ 3 Campus Travel Game This lab will practice using loops. We will construct a...
Language: C++ 3 Campus Travel Game This lab will practice using loops. We will construct a short computer game. Please look at the Test Cases for exact wording. For your game, the player’s goal is to reach campus exactly. The player starts 14 miles away and has up to 4 turns to reach campus. At each turn the play can ride either use a Bus, a Subway, or a Jetpack: Riding a Bus moves the player forward 2 miles each...
Upon completion of your nursing degree, you decided to try the country life, and moved to...
Upon completion of your nursing degree, you decided to try the country life, and moved to a rural town in West Virginia, working for a small family practice. Around mid-September, a man in his late 40’s comes in to your office. He has been suffering from an intermittent headache with a fever of 102-103°F for the past two weeks. The physician arrives while you are completing his vitals (nothing abnormal was noted). The physician takes the man’s history, and performs...
Scenario: Upon successful completion of the MBA program, imagine you work in the analytics department for...
Scenario: Upon successful completion of the MBA program, imagine you work in the analytics department for a consulting company. Your assignment is to analyze one of the following databases: Manufacturing Hospital Consumer Food Financial Select one of the databases based on the information in the Signature Assignment Options. Provide a 1,600-word detailed, four part, statistical report with the following sections: Part 1 - Preliminary Analysis Part 2 - Examination of Descriptive Statistics Part 3 - Examination of Inferential Statistics Part...
Upon the successful completion of this module, you should understand the following concepts: IN YOUR OWN...
Upon the successful completion of this module, you should understand the following concepts: IN YOUR OWN WORDS AND SHOULD BE AT LEAST 100 WORDS 1- Networking 2- Negotiations process 3- Ethics and influencing
Upon the successful completion of this module, you should understand the following concepts: IN YOUR OWN...
Upon the successful completion of this module, you should understand the following concepts: IN YOUR OWN WORDS AND SHOULD BE AT LEAST 100 WORDS 1- Different sources and appropriate uses of power 2- Political behaviour 3- Developing political skills 4- Networking 5- Negotiations process 6- Ethics and influencing
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT