Ok so while reviewing this code which is meant to convert yards, and feet to inches I found on lines 17-19 , and 32. There are "string data" (if that makes sense) as parameters in each method? What do they denote, serve , and their purpose?
MSDN usually has convoluted explanations.....on this so I guess im resorting to you faithful guys again!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Lab1
{
class Lab1
{
static void Main()
{
int inches,
yards,
feet;
// this prepares to write code to give the instructions to the user
DisplayInstructions();
inches = GetInches("inches"); //why is a string(parameter) inside a method.
feet = GetInches("feet");
yards = GetInches("yards");
DisplayResults(inches, yards, feet);
}
// this method will "DisplayInstructions" to the user
public static void DisplayInstructions()
{
Console.WriteLine("This applications will allow the user to input data in yards, feet and inches " +
"& then convert that data into inches.\n");
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
Console.Clear();
}
// This method will acquire the value in inches according to user input
public static int GetInches(string whichOne)
{
Console.Write("Please enter in the {0}: ", whichOne);
return int.Parse(Console.ReadLine());
}
//this method will convert a value given in yards to inches
public static int ConvertYards(int yards)
{
return yards * 36;
}
// this method will convert feet to inches
public static int ConvertFeet(int feet)
{
return feet * 12;
}
// this method will display the results of converting , inches, yards, and feet to inches
public static void DisplayResults(int inches, int yards, int feet)
{
Console.Clear();
Console.WriteLine("Inches: {0:n1}" +
"\nFeet: {1:n1}" +
"\nYards: {2:n1}" +
"\nFeet to Inches: {3:n1}" +
"\nYards to Inches: {4:n1}", inches
, feet
, yards
, ConvertFeet(feet)
, ConvertYards(yards));
Console.ReadKey();
}
}
}
Many Thanks!