class Program
{
//read and write to cmd
static void Main(string[] args)
{
Console.WriteLine("Welcome to the Volume Helper");
Console.WriteLine(" ");
Console.WriteLine("Please Chose a Option:");
Console.WriteLine("1.Cylinder");
Console.WriteLine("2.Cone");
Console.WriteLine("3.Spher");
Console.WriteLine("4.Exit");
Console.ReadLine();
}
// getuserinput
static void getuserinput(string Cylinder, string Cone, string Spher)
{
Console.ReadKey();
}
static void getuseraction(string volume);
{
Console.writeline("the volume is ");
}
// Gets the volume of a Cylinder.
static Double Cylinder(Double Radius, Double Height)
{
Double pi = 3.14159;
Double volume = pi * (Radius * Radius) * Height;
return volume;
}
// Gets the volume of a Sphere.
static Double Sphere(Double Radius)
{
Double fraction = (4 / 3);
Double pi = 3.14159;
Double volume = fraction * pi * (Radius * Radius * Radius);
return volume;
}
// Gets the volume of a Cone.
static Double Cone(Double Base, Double Height, Double Radius)
{
Double fraction = 1 / 3;
Double pi = 3.14159;
Double volume = fraction * pi * (Radius * Radius) * Height;
return volume;
}
}
}
2 Replies - 247 Views - Last Post: 04 October 2012 - 02:04 AM
#1
How Userinput in Console call method and output userinput
Posted 03 October 2012 - 09:30 PM
Hi i am lost on how to get the console to take a menu list and take the user input 1 to 4 and call mehod to output the volume of Cylinder,Cone,spher this what i got so far but lost on how to implement it .
Replies To: How Userinput in Console call method and output userinput
#2
Re: How Userinput in Console call method and output userinput
Posted 03 October 2012 - 10:05 PM
You are already outputting the menu. To get the user's input, collect the return value of Console.ReadLine() that you have on line 16.
http://msdn.microsof...e.readline.aspx
And then the same way you prompted with menu and got the menu choice, you should prompt and read the appropriate inputs for the computation that is needed. e.g. ask for the radius, height, and/or base. Once you have those values, you can pass them to your functions. You have covered function calls in your class, right? Otherwise, why would you have written those functions unless you are cribbing them from somebody else.
http://msdn.microsof...e.readline.aspx
And then the same way you prompted with menu and got the menu choice, you should prompt and read the appropriate inputs for the computation that is needed. e.g. ask for the radius, height, and/or base. Once you have those values, you can pass them to your functions. You have covered function calls in your class, right? Otherwise, why would you have written those functions unless you are cribbing them from somebody else.
#3
Re: How Userinput in Console call method and output userinput
Posted 04 October 2012 - 02:04 AM
Skydiver, on 03 October 2012 - 10:05 PM, said:
You are already outputting the menu. To get the user's input, collect the return value of Console.Read Line() that you have on line 16.
http://msdn.microsof...e.readline.aspx
And then the same way you prompted with menu and got the menu choice, you should prompt and read the appropriate inputs for the computation that is needed. e.g. ask for the radius, height, and/or base. Once you have those values, you can pass them to your functions. You have covered function calls in your class, right? Otherwise, why would you have written those functions unless you are cribbing them from somebody else.
http://msdn.microsof...e.readline.aspx
And then the same way you prompted with menu and got the menu choice, you should prompt and read the appropriate inputs for the computation that is needed. e.g. ask for the radius, height, and/or base. Once you have those values, you can pass them to your functions. You have covered function calls in your class, right? Otherwise, why would you have written those functions unless you are cribbing them from somebody else.
Hi thank you for reply i forgot how to its been about 9 months that i write a console so i basically forgot the steps thank you for the refresher and the link
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|