Question

In: Computer Science

c# In Chapter 2, you created an interactive application named MarshallsRevenue. The program prompts a user...

c#

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 Marshall’s 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

using System;
using static System.Console;
class MarshallsRevenue
{
static void Main()
{
const int INTERIOR_PRICE = 500;
const int EXTERIOR_PRICE = 750;
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);
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);
}
}

Solutions

Expert Solution

Code Screenshots:

Sample Output:

Code to Copy:

using System;

using static System.Console;

class MarshallsRevenue

{

  static void Main()

  {

    const int INTERIOR_PRICE = 500;

    const int EXTERIOR_PRICE = 750;

    string entryString;

    int numInterior;

    int numExterior;

    int revenueInterior;

    int revenueExterior;

    int total;

      bool isInteriorGreater;

    // Declare the

    // required variables.

    bool is_valid_month = true;

    int month;

    int month_inter_price = INTERIOR_PRICE;

    int month_exter_price = EXTERIOR_PRICE;

    

    // Prompt te user

    // to enter the month.

    Write("Enter number of month being scheduled >> ");

    // Read the input.

    entryString = ReadLine();

    // Convert the input to an integer.

    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);

    

    // Use a switch case to perform the

    // action as per the entered month.

    switch(month)

    {

      // Set the exterior murals

      // to zero for the month

      // December through February.

      case 1:

      case 2:

      case 12:

      numExterior = 0;

      break;

      // If the month is either

      // one of April, May, September

      // or October, reduce the price

      // of exterior murals.

      case 4:

      case 5:

      case 9:

      case 10:

      month_exter_price = 699;

      break;

      // If the month is either

      // July or August

      // or October, reduce the price

      // of interior murals.

      case 7:

      case 8:

      month_inter_price = 450;

      break;

      // Do nothing for the

      // month of March, June,

      // and November.

      case 3:

      case 6:

      case 11:

      break;

      // If the entered month is

      // invalid, display an error

      // message and set the

      // is_valid_month to false.

      default:

      WriteLine("The entered month is invalid.");

      is_valid_month = false;

      break;

    }

    // If the entered month is

    // valid, perform the

    // calculations and display the results.

    if(is_valid_month)

    {

      revenueInterior = numInterior * month_inter_price;

      revenueExterior = numExterior * month_exter_price;

      total = revenueInterior + revenueExterior;

      isInteriorGreater = numInterior > numExterior;

      WriteLine("{0} interior murals are scheduled at {1} each for a total of {2}",

      numInterior, month_inter_price.ToString("C"), revenueInterior.ToString("C"));

      WriteLine("{0} exterior murals are scheduled at {1} each for a total of {2}",

      numExterior, month_exter_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);

    }

    

  }

}


Related Solutions

This is C# programming. In Chapter 2, you created an interactive application named GreenvilleRevenue. The program...
This is C# programming. In Chapter 2, you created an interactive application named GreenvilleRevenue. The program prompts a user for the number of contestants entered in this year’s and last year’s Greenville Idol competition, and then it displays the revenue expected for this year’s competition if each contestant pays a $25 entrance fee. The programs also display a statement that compares the number of contestants each year. Now, replace that statement with one of the following messages: If the competition...
You are required to write an interactive program that prompts the user for two integers X...
You are required to write an interactive program that prompts the user for two integers X and Y and performs the following tasks: Adds two numbers Subtracts Y from X Multiplies X and Y Divides X by Y Finds which numbers is larger X oy Y) Prints all the results (a , b, c, d, and e) Program requirements: -     The program should run as many times as the users wish -     The program should be fully documented. -   ...
Write an application named MultiplicationTable that prompts the user for an integer value, for example 7....
Write an application named MultiplicationTable that prompts the user for an integer value, for example 7. Then display the product of every integer from 1 through 10 when multiplied by the entered value. For example, the first three lines of the table might read 1×7=7 , 2×7=14 , and 3×7=21 using a Loop other than While if
( USE C++ ) The program prompts the user to enter a word. The program then...
( USE C++ ) The program prompts the user to enter a word. The program then prints out the word with letters in backward order. For example, if the user enter "hello" then the program would print "olleh" show that it works .
Write a C++ program that prompts the user for the radius of a circle and then...
Write a C++ program that prompts the user for the radius of a circle and then calls inline function circleArea to calculate the area of that circle. It should do it repeatedly until the user enters -1. Use the constant value 3.14159 for π Sample: Enter the radius of your circle (-1 to end): 1 Area of circle with radius 1 is 3.14159 Enter the radius of your circle (-1 to end): 2 Area of circle with radius 2 is...
Write an interactive program in c++ that allows the user toenter 2-15 vectors (use the...
Write an interactive program in c++ that allows the user to enter 2-15 vectors (use the if statement). Display the resultant on the screen.
Create in java an interactive GUI application program that will prompt the user to use one...
Create in java an interactive GUI application program that will prompt the user to use one of three calculators, label project name MEDCALC. You can use any color you want for your background other than grey. Be sure to label main java box with “MEDCALC” and include text of “For use only by students” On all three calculators create an alert and signature area for each user. The alert should be something like “All calculations must be confirmed by user...
write this program in C++ Write a program that prompts a user for three characters. The...
write this program in C++ Write a program that prompts a user for three characters. The program must make sure that the input is a number 10 - 100 inclusive. The program must re prompt the user until a correct input is entered. Finally output the largest and the lowest value. Example 1: Input : 10 Input : 20 Input : 30 The largest is 30. The lowest is 10. Example 2: Input : 100 Input : 50 Input :...
Write a C++ Program Write a program that prompts the user to input a string. The...
Write a C++ Program Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must insert the following comments at the beginning...
C# Create a console application that prompts the user to enter a regular expression, and then...
C# Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a regular expression...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT