Question: Using C# and including comments. using System; using static System.Console; namespace CarpetExample { class CarpetCalculator { static void Main( ) { const int SQ_FT_PER_SQ_YARD =
Using C# and including comments.
using System; using static System.Console; namespace CarpetExample { class CarpetCalculator { static void Main( ) { const int SQ_FT_PER_SQ_YARD = 9; const int INCHES_PER_FOOT = 12; const string BEST_CARPET = "Berber"; const string ECONOMY_CARPET = "Pile"; int roomLengthFeet = 12, roomLengthInches = 2, roomWidthFeet = 14, roomWidthInches = 7; double roomLength, roomWidth, carpetPrice, numOfSquareFeet, numOfSquareYards, totalCost; roomLength = roomLengthFeet + roomLengthInches / INCHES_PER_FOOT; roomWidth = roomWidthFeet + roomWidthInches / INCHES_PER_FOOT; numOfSquareFeet = roomLength * roomWidth; numOfSquareYards = numOfSquareFeet / SQ_FT_PER_SQ_YARD; carpetPrice = 27.95; totalCost = numOfSquareYards * carpetPrice; WriteLine("{0,12}", "Carpet App"); WriteLine( ); WriteLine("{0,-7}{1,8:C}", BEST_CARPET + ":", totalCost); WriteLine( ); carpetPrice = 15.95; totalCost = numOfSquareYards * carpetPrice; WriteLine("{0,-7}{1,8:C}", ECONOMY_CARPET + ":", totalCost); ReadKey(); } } } Create a console application called CarpetExample and inside that application create a class named CarpetCalculator.cs (note that the class and the project names are different). Initially your code should start off the same as what is given In the textbook: CarpetCalcu1ator.cs Modify this code so that it asks the user for the width and the length instead of setting those values when they are initialized. Example: What is the length in toot ? 10 What is the length in additional inches? 4 What is the width in foot? 15 What is the width in additional inches? 5 Carpet App Berber: $465.83 Pile: $265.83
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
