Question: All in C# and I'm using switch/case statements right now. The lesson is to do something else than if/else. In Chapter 2, you created an
All in C# and I'm using switch/case statements right now. The lesson is to do something else than "if/else".
In Chapter 2, you created an interactive application named MarshallsRevenue. The program prompts a user for the number of interior and exterior murals scheduled to be painted during the next month by Marshalls Murals. Next, the programs compute the expected revenue for each type of mural when interior murals cost $500 each and exterior murals cost $750 each.
The application also displays the total expected revenue and a statement that indicates whether more interior murals are scheduled than exterior ones. Now, modify the application to accept a numeric value for the month being scheduled and to modify the pricing as follows: Because of uncertain weather conditions, exterior murals cannot be painted in December through February, so change the number of exterior murals to 0 for those months. Marshall prefers to paint exterior murals in April, May, September, and October. To encourage business, he charges only $699 for an exterior mural during those months. Murals in other months continue to cost $750. Marshall prefers to paint interior murals in July and August, so he charges only $450 for an interior mural during those months. Murals in other months continue to cost $500.
I have these errors. A lot are about '=' which makes no sense! Starting from line 123, the statements at the bottom. I also feel like my switch/case is messed up. I'm new to C#!
This is my C# code:
using System; using static System.Console; class MarshallsRevenue { static void Main() { const int INTERIOR_PRICE = 500; const int INTERIOR_DISCOUNT = 450; int month; int interiorRate; int exteriorRate; const int EXTERIOR_PRICE = 750; const int EXTERIOR_DISCOUNT = 699; string entryString; int numInterior; int numExterior; int revenueInterior; int revenueExterior; int total; bool isInteriorGreater; Write("Enter number of interior murals scheduled >> "); entryString = ReadLine(); numInterior = Convert.ToInt32(entryString); Write("Enter number of exterior murals scheduled >> "); entryString = ReadLine(); numExterior = Convert.ToInt32(entryString); Write("What month do you want the artist to paint the mural? >> "); entryString = ReadLine(); month = Convert.ToInt32(entryString); switch(month) { case 12: case 1: case 2: { exteriorRate = 0; interiorRate = INTERIOR_PRICE; WriteLine ("I don't work on external murals this month"); break; } case 3: { interiorRate = INTERIOR_PRICE; exteriorRate = EXTERIOR_PRICE; break; } case 4: { exteriorRate = EXTERIOR_DISCOUNT; interiorRate = INTERIOR_PRICE; break; } case 5: { exteriorRate= EXTERIOR_DISCOUNT; interiorRate = INTERIOR_PRICE; break; } case 6: { exteriorRate = EXTERIOR_PRICE; interiorRate = INTERIOR_DISCOUNT; break; } case 7: { exteriorRate = EXTERIOR_PRICE; interiorRate = INTERIOR_DISCOUNT; break; } case 8: { exteriorRate = EXTERIOR_PRICE; interiorRate = INTERIOR_DISCOUNT; break; } case 9: { exteriorRate = EXTERIOR_DISCOUNT; interiorRate = INTERIOR_PRICE; break; } case 10: { exteriorRate = EXTERIOR_DISCOUNT; interiorRate = INTERIOR_PRICE; break; } case 11: { exteriorRate = EXTERIOR_PRICE; interiorRate = INTERIOR_PRICE; break; }
} } revenueInterior = numInterior * INTERIOR_PRICE; revenueExterior = numExterior * EXTERIOR_PRICE; total = revenueInterior + revenueExterior; isInteriorGreater = numInterior > numExterior; WriteLine("{0} interior murals are scheduled at {1} each for a total of {2}", numInterior, INTERIOR_PRICE.ToString("C"), revenueInterior.ToString("C")); WriteLine("{0} exterior murals are scheduled at {1} each for a total of {2}", numExterior, EXTERIOR_PRICE.ToString("C"), revenueExterior.ToString("C")); WriteLine("Total revenue expected is {0}", total.ToString("C")); WriteLine("It is {0} that there are more interior murals scheduled than exterior ones.", isInteriorGreater); } }
Thank you so much!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
