Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7169561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:01:10+00:00 2026-05-28T15:01:10+00:00

I’m new to C#, well, coding in general. I have done fairly well by

  • 0

I’m new to C#, well, coding in general.
I have done fairly well by myself to date, in this introduction course I am taking, but I ran into a road bump.

I am trying to figure out how to code a if statement that will run inside a loop to analyze 5 different ints as they are entered and to put the max int and min int seperatly so that I can ue the remaining three ints to make a calculation.
To be exact, validate user input and remove the min/max user input to average the remaining three.

PS, I tried an array but for some reason it wasn’t working well. I don’t have the code as I’m at work right now though. I was told in a lecture that an if statement should be used but arrays are possible too.

Thank you for your time and any possible answers.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string userIsFinished = "";
            string name, city, value;
            double rating, avg = 0;
            double[] array1 = new double[5];
            double max = 0;
            double min = double.MaxValue;
            double score, totalScore = 0;


            //get basic information
            do
            {
                Console.WriteLine("Please enter divers name.");
                name = Console.ReadLine();
                Console.WriteLine("Please enter the divers city.");
                city = Console.ReadLine();



                //get and validate user input for 1 dive rating
                Console.WriteLine("Please enter a dive rating between 1.00 and 1.67.");
                rating = Double.Parse(Console.ReadLine());
                while (rating < 1 || rating > 1.69)
                {
                    Console.WriteLine("Oops, you entered an invalid number. Please, enter a dive rating between 1.00 and 1.67.");
                    rating = Double.Parse(Console.ReadLine());
                }
                Console.ReadLine();

                // get and validate user input for 5 judge scores
                for (int s = 1; s <= 5; s++)
                {
                    Console.WriteLine("Please enter the score for judge {0}.", s);
                    value = Console.ReadLine();
                    score = Convert.ToDouble(value);
                    while (score < 0 || score > 10)
                    {
                        Console.WriteLine("Invalid entry, please enter a number in between 0 - 10.");
                        score = Convert.ToDouble(Console.ReadLine());
                    }
                    array1[s] = Convert.ToDouble(score);     //----this line keeps throwing an exception
                }
                Console.ReadLine();

                //calculate totalScore by dropping min/max scores and averaging them times dive rating
                foreach (int i in array1)
                {
                    if (i > max)
                        max = i;
                    if (i < min)
                        min = i;
                    avg += i;
                }
                totalScore = avg * rating;

                //Print gathered and calculated information
                Console.WriteLine("Divers name: {0}", name);
                Console.WriteLine("Divers city: {0}", city);
                Console.WriteLine("Dive degree of difficulty: {0}", rating);
                Console.WriteLine("Total dive score is: {0}", totalScore);

                // Ask if user wants to process another diver and continue or exit program
                Console.WriteLine("Would you like to enter another divers information? [Y]es [N]o: ");
                userIsFinished = Console.ReadLine();
            }
            while
            (userIsFinished.ToLower() != "n");
            Console.ReadLine();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:01:13+00:00Added an answer on May 28, 2026 at 3:01 pm

    Not sure about your question… You want to know, the max and min about 5 values, and the avarage about the three others…

    int[] n = { 4, 7, 29, 3, 87 };
    int max = 0;
    int min = int.MaxValue;
    double avg = 0;
    
    foreach (int i in n)
    {
        if (i > max)
            max = i;
    
        if (i < min)
           min = i;
    
       avg += i;
    }
    
    avg = avg / n.Count - 2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.