Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Ive been working on this code and Ive got myself lost. Im only supposed to have

ID: 3864865 • Letter: I

Question

Ive been working on this code and Ive got myself lost. Im only supposed to have 3 methods, but I feel like I cant do it with only 3 methods so Ive just been playing around with the code and have it all screwed up now.

The objectives are as follows.

C# program that will accept multiple values from user and let them know if its in acceptable range of 0 to 100.

Requirements

1-create a method that will display the instructions and information about the program.

2-create a method that displays the prompt as to whether you wish to enter another value

3-create a method that requests the input from the user

Here is my crappy code.

________________________________________

using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter6Homework1
{
    class Ch6Program1
    {
        static void Main(string[] args)
        {
            int value;
            string moreEntries;


        }

        //Display Instructions
        public static void DisplayInstructions()
        {
            WriteLine("*****    *****   *****   *****   *****   *****");
            WriteLine(" This application lets you enter as many values as you want.");
            WriteLine(" It will then test the values you entered to see if they are within the acceptable range of 0 to 100");
        }

        //Input From User
        public static double GetInput()
        {
            double value;
            WriteLine("Please enter a positive value less than 100:");
            if
                (double.TryParse(ReadLine(),out value) == false)
            {
                WriteLine("Invalid value entered");
            }
            return value;
        }

        //Enter another value question
        public static void GetMultiInput()
        {
            string moreEntries;
            WriteLine(" Would you like to enter another value? Enter Y to continue or N to exit and get results.");
            moreEntries = ReadLine();
            return moreEntries;

        }


        //Enter correct display values
        public static void DisplayResults()  
        {
            WriteLine(" Number of Valid values entered during testing: *****show number of values entered*");
            WriteLine("Number of Invalid values entered: ******show number of invalid values entered for testing*");
            WriteLine(" Values outside of range: *******show number outside range*");
            WriteLine("Non - Numeric values entered: *******show number of non - numeric vaues entered*");

        }
    }
}

Explanation / Answer

// C# code
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chapter6Homework1
{
class Ch6Program1
{
static void Main(string[] args)
{
double value;
string moreEntries;
DisplayInstructions();
  
int countinRange=0;
int countoutrange = 0;
int countTotal;
int countnonnumeric = 0;
  
while(true)
{
value = GetInput();
if(value == -99999)
countnonnumeric = countnonnumeric + 1;
else if(value >= 0 && value <= 100)
countinRange = countinRange + 1;
else
countoutrange = countoutrange + 1;
  
moreEntries = GetMultiInput();
if(moreEntries.Equals("N"))
break;
  
}
DisplayResults(countoutrange,countinRange,countnonnumeric);
}

//Display Instructions
public static void DisplayInstructions()
{
WriteLine("***** ***** ***** ***** ***** *****");
WriteLine(" This application lets you enter as many values as you want.");
WriteLine(" It will then test the values you entered to see if they are within the acceptable range of 0 to 100");
}
//Input From User
public static double GetInput()
{
double value;
WriteLine("Please enter a positive value less than 100:");
if(double.TryParse(ReadLine(),out value) == false)
{
WriteLine("Invalid value entered");
return -99999;
}
return value;
}
//Enter another value question
public static string GetMultiInput()
{
string moreEntries;
WriteLine(" Would you like to enter another value? Enter Y to continue or N to exit and get results.");
moreEntries = Console.ReadLine();
return moreEntries;
}

//Enter correct display values
public static void DisplayResults(int countoutrange, int countinrange, int countnonnumeric)
{
WriteLine("Number of Valid values entered during testing: {0}",countinrange);
WriteLine("Number of Invalid values entered:{0}",countnonnumeric);
WriteLine("Values outside of range: {0}",countoutrange);
WriteLine("Non - Numeric values entered: {0}",countnonnumeric);

}
}
}

/*
output:

***** ***** ***** ***** ***** *****
  
This application lets you enter as many values as you want.   
  
It will then test the values you entered to see if they are within the acceptable range of 0 to 100   
Please enter a positive value less than 100:
1   
  
Would you like to enter another value?
Enter Y to continue or N to exit and get results.   
y
Please enter a positive value less than 100:
56
  
Would you like to enter another value?
Enter Y to continue or N to exit and get results.   
y   
Please enter a positive value less than 100:
-12   
  
Would you like to enter another value?
Enter Y to continue or N to exit and get results.   
y   
Please enter a positive value less than 100:
abc   
Invalid value entered   
  
Would you like to enter another value?
Enter Y to continue or N to exit and get results.   
Y
Please enter a positive value less than 100:
23
  
Would you like to enter another value?
Enter Y to continue or N to exit and get results.   
N '

Number of Valid values entered during testing: 3
Number of Invalid values entered:1
Values outside of range: 1
Non - Numeric values entered: 1

*/