ok so im making this console app in which I have to allow the user to enter any number of values then display orignal value , and then the percentage of the original value to the total. My question is how do I initialize my memory locations correctly for a correct report to display ?
also is my method of asking for more values correct?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class intReport
{
static void Main()
{
//declare memory locations
//
//user provided value
int userInteger = 1;
int userTotal= 1; //totals the value user provides
double percentage = (userInteger / userInteger) * 100;
string userInput; //read user input
bool dataOutput = true;
DisplayInstructions();
while (dataOutput)
{
userInteger = GetInput();
DisplayReport(userInteger, userTotal, percentage);
Console.WriteLine("Would you like to enter additional values?");
userInput = Console.ReadLine();
if (userInput == "y" || userInput == "Y")
{
Console.Clear();
}
else
dataOutput = false;
} // end of while loop
} // end of main
public static void DisplayInstructions()
{
Console.Write("In this program you will be allowed to enter any number of values the program" +
"\n will then total the values and display a report which will show the original"+
"\nentered value as a percentage of the total" +
"\n\n Please press any key to continue.") ;
Console.ReadKey();
Console.Clear();
} //end of display instructions
public static int GetInput()
{
int input;
Console.WriteLine("You will be asked to enter a integer.");
Console.WriteLine(" ");
Console.Write("Please enter a value: ");
int.TryParse(Console.ReadLine(), out input);
Console.Clear();
return input;
} // end of GetInput method
public static double Percentage(int userInteger, int userTotal, double percentage)
{
//int userInteger;
//int userTotal;
//double percentage;
Console.WriteLine("Original Value = {0} ", userInteger);
Console.WriteLine("Org. Value Percentage to the total = {0} ", percentage);
return percentage;
} //end of percentage method
public static void DisplayReport(int userInteger, int userTotal, double percentage)
{
int i;
Console.Write("\n");
Console.WriteLine("Your Results: ");
Console.WriteLine("------------- ");
Console.WriteLine("Original Value: {0}", userInteger);
Console.WriteLine("Percentage: {0}", percentage);
} // emd of display report
} // end of class
} // end of namespace