Question

In Chapter 4 of your book, you created an interactive application named MarshallsRevenue that prompts a...

In Chapter 4 of your book, you created an interactive application named MarshallsRevenue that prompts a user for the number of interior and exterior murals scheduled to be painted during a month and computes the expected revenue for each type of mural. The program also prompts the user for the month number and modifies the pricing based on requirements listed in Chapter 4.

Now, modify the program so that the user must enter a month value from 1 through 12. If the user enters an incorrect number, the program prompts for a valid value. Also, the user must enter a number between 0 and 30 inclusive for the number of murals of each type; otherwise, the program prompts the user again.

For example, if I input: 4, 5, 8

Expected output: 500, 2250, 750, 6000, 8250

The code is:

using System;
using static System.Console;
class MarshallsRevenue
{
static void Main()
{
const int INTERIOR_PRICE = 500;
const int EXTERIOR_PRICE = 750;
const int DISCOUNT_INTERIOR_PRICE = 450;
const int DISCOUNT_EXTERIOR_PRICE = 699;
string entryString;
int month;
int numInterior;
int numExterior;
int revenueInterior;
int revenueExterior;
int total;
bool isInteriorGreater;
Write("Enter the month >> ");
entryString = ReadLine();
month = Convert.ToInt32(entryString);
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);
if(month == 12 || month ==1 || month == 2)
numExterior = 0;
if(month == 4 || month == 5 || month ==9 || month == 10)
revenueExterior = numExterior * DISCOUNT_EXTERIOR_PRICE;
else
revenueExterior = numExterior * EXTERIOR_PRICE;
if(month == 7 || month == 8)
revenueInterior = numInterior * DISCOUNT_INTERIOR_PRICE;
else
revenueInterior = numInterior * INTERIOR_PRICE;
total = revenueInterior + revenueExterior;
isInteriorGreater = numInterior > numExterior;
WriteLine("{0} interior murals are scheduled for a total of {1}",
numInterior, revenueInterior.ToString("C"));
WriteLine("{0} exterior murals are scheduled for a total of {1}",
numExterior, 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);
}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System;
using static System.Console;
class MarshallsRevenue
{
static void Main()
{
const int INTERIOR_PRICE = 500;
const int EXTERIOR_PRICE = 750;
const int DISCOUNT_INTERIOR_PRICE = 450;
const int DISCOUNT_EXTERIOR_PRICE = 699;
string entryString;
int month;
int numInterior;
int numExterior;
int revenueInterior;
int revenueExterior;
int total;
bool isInteriorGreater;
Write("Enter the month >> ");
entryString = ReadLine();
month = Convert.ToInt32(entryString);

while(!(month >=1 && month <=12)){
  
Write("Invalid Month , Enter the month between (1-12) >> ");
entryString = ReadLine();
month = Convert.ToInt32(entryString);

}
Write("Enter number of interior murals scheduled >> ");
entryString = ReadLine();
numInterior = Convert.ToInt32(entryString);

while(!(numInterior >=0 && numInterior <=30)){
  
Write("Invalid number of interior murals , Enter number of interior murals scheduled (0-30) >> ");
entryString = ReadLine();
numInterior = Convert.ToInt32(entryString);

}
Write("Enter number of exterior murals scheduled >> ");
entryString = ReadLine();
numExterior = Convert.ToInt32(entryString);

while(!(numExterior >=0 && numExterior <=30)){
  
Write("Invalid number of exterior murals , Enter number of exterior murals scheduled (0-30) >> ");
entryString = ReadLine();
numExterior = Convert.ToInt32(entryString);
}
if(month == 12 || month ==1 || month == 2)
numExterior = 0;
if(month == 4 || month == 5 || month ==9 || month == 10)
revenueExterior = numExterior * DISCOUNT_EXTERIOR_PRICE;
else
revenueExterior = numExterior * EXTERIOR_PRICE;
if(month == 7 || month == 8)
revenueInterior = numInterior * DISCOUNT_INTERIOR_PRICE;
else
revenueInterior = numInterior * INTERIOR_PRICE;
total = revenueInterior + revenueExterior;
isInteriorGreater = numInterior > numExterior;
WriteLine("{0} interior murals are scheduled for a total of {1}",
numInterior, revenueInterior.ToString("C"));
WriteLine("{0} exterior murals are scheduled for a total of {1}",
numExterior, 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);
}
}

-------------------------------------------------------------------------------------------------

SEE OUTPUT

Thanks, PLEASE COMMENT if there is any concern. PLEASE UPVOTE

Add a comment
Know the answer?
Add Answer to:
In Chapter 4 of your book, you created an interactive application named MarshallsRevenue that prompts a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Chapter 11, you created the most recent version of the GreenvilleRevenue program, which prompts the...

    In Chapter 11, you created the most recent version of the GreenvilleRevenue program, which prompts the user for contestant data for this year’s Greenville Idol competition. Now, save all the entered data to a Greenville.ser file that is closed when data entry is complete and then reopened and read in, allowing the user to view lists of contestants with requested talent types. The program should output the name of the contestant, the talent, and the fee. using System; using static...

  • In Chapter 1, you created two programs to display the motto for the Greenville Idol competition...

    In Chapter 1, you created two programs to display the motto for the Greenville Idol competition that is held each summer during the Greenville County Fair. Now write a program named GreenvilleRevenue that prompts a user for the number of contestants entered in last year’s competition and in this year’s competition. Display all the input data. Compute and display the revenue expected for this year’s competition if each contestant pays a $25 entrance fee. Also display a statement that indicates...

  • Use a C# In previous chapters, you have created programs for the Greenville Idol competition. Now...

    Use a C# In previous chapters, you have created programs for the Greenville Idol competition. Now create a Contestant class with the following characteristics: The Contestant class contains public static arrays that hold talent codes and descriptions. Recall that the talent categories are Singing, Dancing, Musical instrument, and Other. Name these fields talentCodes and talentStrings respectively. The class contains an auto-implemented property Name that holds a contestant’s name. The class contains fields for a talent code (talentCode) and description (talent)....

  • Modify the code, so that it will check the various user inputs for validity (e.g., months...

    Modify the code, so that it will check the various user inputs for validity (e.g., months being between 1 - 12), - if invalid value was entered, ask user to enter a new (& correct) value, - check to see if new value is valid - if valid allow the user to continue. - if still not valid repeat this process, until valid value is entered __________________________________________________________________________________________________ QUESTION: Desc: This program creates a painting order receipt. Ask for the following...

  • In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now,...

    In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now, using the code you wrote in Chapter 5, Programming Exercise 5, modify the program to use arrays to store the salesperson names, allowed initials, and accumulated sales values. In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format...

  • In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now,...

    In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now, using the code you wrote in Chapter 5, Programming Exercise 5, modify the program to use arrays to store the salesperson names, allowed initials, and accumulated sales values. In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format...

  • The following file has syntax and/or logical errors. In each case, determine the problem, and fix...

    The following file has syntax and/or logical errors. In each case, determine the problem, and fix the program. using System; using static System.Console; using System.IO; class DebugFourteen1 { static void Main() { string fileName; string directory; string path; string files; int x; Write("Enter a directory: "); directory = ReadLine(); if(Directory.Exists(Directory)) { files = Directory.GetFiles(directory); if(files.Length = 0) WriteLine("There are no files in " + directory); else { WriteLine(directory + " contains the following files"); for(x = 0; x <= files.Length;...

  • I need help with the following assignment: Write an application named DailyTemps that continuously prompts a...

    I need help with the following assignment: Write an application named DailyTemps that continuously prompts a user for a series of daily high temperatures until the user enters a sentinel value of 999. Valid temperatures range from -20 through 130 Fahrenheit. When the user enters a valid temperature, add it to a total; when the user enters an invalid temperature, display the error message: Valid temperatures range from -20 to 130. Please reenter temperature. Before the program ends, display the...

  • Write a program named CheckMonth2 that prompts a user to enter a birth month and day....

    Write a program named CheckMonth2 that prompts a user to enter a birth month and day. Display an error message that says Invalid date if the month is invalid (not 1 through 12) or the day is invalid for the month (for example, not between 1 and 31 for January or between 1 and 29 for February). If the month and day are valid, display them with a message. For example, if the month entered is 2, and the day...

  • Name : StarryArrays Write a program called StarryArrays which prompts user for the number of items...

    Name : StarryArrays Write a program called StarryArrays which prompts user for the number of items in an array (a non-nega- tive integer), and saves it in an int variable called numltems. It then prompts user for the values of all the items (non-negative integers) and saves them in an int array called items. The program shall then print the contents of the array in a graphical form, with the array index and values represented by number of stars For...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT