Desks - part 2

using System; // app named Desks public class Desks { // has main() public static void Main() { Console.WriteLine("In main()"); // set up the variables Main() will need. int numDrawers; char woodType; float cost; // Call the method to get the number of drawers from the user numDrawers = getNumDrawers(); Console.WriteLine("You chose {0} drawers for this desk.", numDrawers); return; } // -method - accepts input for number of drawers from user, returns that number to main() public static int getNumDrawers() { Console.WriteLine("In getNumDrawers()"); string input; Console.WriteLine("How many drawers would you like this desk to have? "); input = Console.ReadLine(); return Convert.ToInt32(input); } // - method - accepts type of wood from user, returns to main() public static char getWoodType() { // -- m=mahogany, o=oak, p=pine Console.WriteLine("In getWoodType()"); return 'a'; } // - method accepts #drawers & wood type, calculates cost, returns to main() public static float calcDeskCost(int numDrawers, char woodType) { // -- pine=$100, oak=$140, other wood = $180 // -- each drawer +$30 Console.WriteLine("In calcDeskCost()"); return 1.0f; } // - method - display all details and final price public static void display(int numDrawers, char woodType, float cost) { Console.WriteLine("in display()"); return; } }
Now lets flesh out getNumDrawers().
Add some variables we will need to Main().
Call the method getNumDrawers.
Print out what was returned.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.