Question 5. 5. (TCOs 5, 6, 8) Write the C# code to for the following problem. De
ID: 663188 • Letter: Q
Question
Question 5. 5. (TCOs 5, 6, 8) Write the C# code to for the following problem.
Declare an array to store five values; they could be decimal numbers.
Prompt the user to store values into the array.
Then prompt the user for a percent to increase each value of the array.
Adjust the values and print the new values. Make sure you actually change the values in the array.
The output should look like this (note that it should work for any values that are input, these are just examples). You must use loop(s) to process the array.
Enter number: 10
Enter number: 20
Enter number: 30
Enter number: 40
Enter number: 50
Enter percent increase: 5
After a 5 percent increase the values are
10.5
21
31.5
42
52.5
Press any key to continue .
Question 5. 5. (TCOs 5, 6, 8) Write the C# code to for the following problem.
Declare an array to store five values; they could be decimal numbers.
Prompt the user to store values into the array.
Then prompt the user for a percent to increase each value of the array.
Adjust the values and print the new values. Make sure you actually change the values in the array.
The output should look like this (note that it should work for any values that are input, these are just examples). You must use loop(s) to process the array.
Enter number: 10
Enter number: 20
Enter number: 30
Enter number: 40
Enter number: 50
Enter percent increase: 5
After a 5 percent increase the values are
10.5
21
31.5
42
52.5
Press any key to continue .
Explanation / Answer
using System;
namespace test
{
class test1
{
static void Main(string[] args)
{
double[] arr1 = new double[5];
double[] modified=new double[5];
for (int p = 0; p < 5; p++)
{
Console.WriteLine("Enter number : ");
arr1[p] = Convert.ToDouble(Console.ReadLine());
}
Console.WriteLine("Enter percent increase");
int increase=Convert.ToInt16(Console.ReadLine());
Console.WriteLine(increase);
for (int t = 0; t < 5; t++)
{
modified[t]=arr1[t]+(increase*arr1[t]*0.01);
Console.WriteLine(modified[t]);
}
//Console.WriteLine("Enter percent increase");
//decimal Per_in=Console.ReadLine();
//foreach (int p in arr1)
//{
// Console.WriteLine(arr1[p]);
//}
Console.ReadLine();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.