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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started