Question: C# Write a program named Desks2 that modifies the Desks program you created in Chapter 7 so that all the methods are void methods and

C# Write a program named Desks2 that modifies the Desks program you created in Chapter 7 so that all the methods are void methods and recive ref or out parameters as appropriate.

*********************************

My code is as follows:

using System; namespace Desks { class Program { const int PINE = 100, OAK = 140, OTHER = 180; const int SURCHARGE = 30; static void Main(string[] args) { int num = numberOfDrawers(); char type = woodType(); displayCost(num, type); } public static int numberOfDrawers() { Console.Write("Enter number of drawers in desk: "); int num = Convert.ToInt32(Console.ReadLine()); return num; } public static char woodType() { Console.Write(" Enter Wood type(m for Mahogony, O for Oak, p for Pine: "); char type = Convert.ToChar(Console.Read()); return type; } public static void displayCost(int num, char type) { int cost = 0; if (type == 'o' || type == 'O') { cost = SURCHARGE * num + OAK; Console.WriteLine("The oak type desk cost is = $" + OAK); Console.WriteLine("Number of drawers are : " + num + " The final cost of desk of type oak is = $" + cost); } else if (type == 'p' || type == 'P') { cost = SURCHARGE * num + PINE; Console.WriteLine("The pine type desk cost is = $" + PINE); Console.WriteLine("Number of drawers are : " + num + " The final cost of desk of of type pine is = $" + cost); } else { cost = SURCHARGE * num + OTHER; Console.WriteLine("The other type desk cost is = $" + OTHER); Console.WriteLine("Number of drawers are : " + num + " The final cost of desk of of type other is = $" + cost); } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!