Write a program that simulates calculation of building cost. This program will a
ID: 3634020 • Letter: W
Question
Write a program that simulates calculation of building cost. This program will ask the user for a number of inputs that you will have to determine based on the problem statement. Your program will then calculate the cost of a building based on these inputs.Problem Statement.
A company would like you to design a program that will generate a building cost that is based on the square feet of the building times the number of floors. The square foot building cost is $100.00/sqft.
Also computed into the cost is the number of windows requested and the number of doors. When a user enters the number of windows or doors you must also determine the type of window or door.
Doors:
• Flat- 100/door
• 3 panel- 150/door
• 5 panel – 200/door
Windows:
• Aluminum -200/window
• Wood – 250/window
• Vinyl – 350/window
You will define a menu method that will allow the user to choose what cost they want to add, and if they want to continue. The application will continue to run until the user enters “quit”
You will define a window cost method that will take as an argument the number of windows they want, inside the method you will identify what type of window they want and then calculate the cost.
This method will return the total cost of all windows.
You will define a door cost method that will take in the number of doors that they want. Inside the method you will determine the type of door and the total cost of all doors. This method will return the total cost of all doors.
You will define a method that calculates the square footage price of the building. This method will take in length and width and the number of floors. (square foot is defined as length * width)
This method will return the total cost of the buildings square foot price.
The last method is the total cost method. This method will take the window, door and square foot cost as parameters it will return the total cost of the building.
Utility methods:
ConvertInput Method. Signature: public static bool ConvertInput(ref string message, string input,string method name, ref double output)
This method will return a bool it will have two reference parameters, and two string by value parameters and a ref double parameter. This method will get the users input and covert from string to double using the parse. It will utilize the try catch to handle format errors.
If there are no format errors then the method will return true and set the reference parameter for output.
If the format fails then the method will return false, and set the reference parameter for message to explain error.
Explanation / Answer
using System; namespace shipping { class Program { static void Main(string[] args) { double saleAmount = 0; double shipping = 0; Console.WriteLine("A program that inputs the amount of the purchase and calculates the shipping charge"); Console.Write("Enter a purchase amount to find out your shipping charges: "); string line = Console.ReadLine(); saleAmount = double.Parse(line); if (saleAmount > 5000) shipping = 20; else if (saleAmount > 1000) shipping = 15.00; else if (saleAmount > 500) shipping = 10.00; else if (saleAmount > 250) shipping = 8.00; else shipping = 5.00; Console.WriteLine(String.Format("Your merchandise in the amount of ${0:f2} will incur a shipping charge of ${1:f2}", saleAmount, shipping)); Console.Write("Press any key to exit..."); Console.ReadKey(false); } } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.