C# program writen in Visual Studio code, I need added on the end the Last Value Divided by the First Value. Here is the code... class Progr
C# program writen in Visual Studio code, I need added on the end the Last Value Divided by the First Value. Here is the code... class Progr
Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter8: Advanced Data Handling Concepts
Section: Chapter Questions
Problem 17RQ
Related questions
Question
100%
For this C# program writen in Visual Studio code, I need added on the end the Last Value Divided by the First Value. Here is the code...
class Program
{
static void Main(string[] args)
{
UniqueValueApp myApp = new UniqueValueApp();
myApp.GetValues();
myApp.DisplayValues();
myApp.minValue();
myApp.maxValue();
myApp.sumOfValues();
myApp.avgOfValues();
}
}
class UniqueValueApp
{
private List<int> _list = new List<int>();
public void GetValues()
{
int value;
bool result;
Console.Write("Please enter an integer: ");
string input = Console.ReadLine();
while (input != null)
{
result = int.TryParse(input, out value);
if (result)
{
if (value > -1 && value < 100)
{
if (!_list.Contains(value))
{
_list.Add(value);
}
if (_list.Count == 5)
{
break;
}
}
else
{
Console.WriteLine("You must enter a value between 0 and 100, inclusive.");
}
}
Console.Write("Please enter an integer: ");
input = Console.ReadLine();
}
}
public void DisplayValues()
{
Console.WriteLine("Unique values entered: ");
foreach (int number in _list)
{
Console.Write(number+" ");
}
}
public void minValue()
{
int min = _list[0];
foreach (int number in _list)
{
if(number < min)
min = number;
}
Console.WriteLine("\nMin Value Entered: "+min);
}
public void maxValue()
{
int max = _list[0];
foreach (int number in _list)
{
if(number > max)
max = number;
}
Console.WriteLine("\nMax Value Entered: "+max);
}
public void sumOfValues()
{
int s = 0;
foreach (int number in _list)
{
s += number;
}
Console.WriteLine("\nSum of Value Entered: "+s);
}
public void avgOfValues()
{
int s = 0;
foreach (int number in _list)
{
s += number;
}
Console.WriteLine("\nAverage of Value Entered: "+(s/5));
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781285196145
Author:
Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:
Cengage Learning