Question

In: Computer Science

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.

Below is the source code

using System;

class MainClass

{

public static void Main (string[] args) //main function

{

//variable declaration

int month,intmu,extmu,total;

total=0;

string[] arr = new string[] {"January", "February", "March", "April", "May",

"June", "July", "August", "September", "October", "November", "December"};

do

{

//accepting the month value from user

Console.WriteLine ("Enter a month number");

month = Convert.ToInt32(Console.ReadLine());

if(month<1 || month >12)

Console.WriteLine ("Enter a valid value between 1 to 12");

}while(month<1 || month >12);

do

{

//accepting interior mural number from user

Console.WriteLine ("Enter number of interior murals");

intmu = Convert.ToInt32(Console.ReadLine());

if(intmu < 0 || intmu >30)

Console.WriteLine ("Enter a valid value between 0 to 30");

}while(intmu < 0 || intmu >30);

do

{

//accepting exterior mural number from user

Console.WriteLine ("Enter number of exterior murals");

extmu = Convert.ToInt32(Console.ReadLine());

if(extmu < 0 || extmu >30)

Console.WriteLine ("Enter a valid value between 0 to 30");

}while(extmu < 0 || extmu >30);

//displaying the data

Console.WriteLine ("Revenue for the month of "+arr[month-1]);

Console.WriteLine("Number of interior murals : "+intmu);

Console.WriteLine("Number of exterior murals : "+extmu);

//calcultaing the total revenue

total=(100*intmu)+(200*extmu);

Console.WriteLine("Total Revenue : Rs "+total);

}

}

Please provide source code and display response.

Solutions

Expert Solution

// do comment if any problem arises

// code

using System;

class MainClass

{

    public static void Main(string[] args) //main function

    {

        //variable declaration

        int month, intmu, extmu, total;

        total = 0;

        string[] arr = new string[] {"January", "February", "March", "April", "May",

"June", "July", "August", "September", "October", "November", "December"};

        //this do-while loop reprompts user to enter month if user enters month <1 or >12

        do

        {

            //accepting the month value from user

            Console.WriteLine("Enter a month number");

            month = Convert.ToInt32(Console.ReadLine());

            if (month < 1 || month > 12)

                Console.WriteLine("Enter a valid value between 1 to 12");

        } while (month < 1 || month > 12);

        //this do-while loop reprompts user to enter internal murals if user enters a value of <0 or >30

        do

        {

            //accepting interior mural number from user

            Console.WriteLine("Enter number of interior murals");

            intmu = Convert.ToInt32(Console.ReadLine());

            if (intmu < 0 || intmu > 30)

                Console.WriteLine("Enter a valid value between 0 to 30");

        } while (intmu < 0 || intmu > 30);

        //this do-while loop reprompts user to enter external murals if user enters a value of <0 or >30

        do

        {

            //accepting exterior mural number from user

            Console.WriteLine("Enter number of exterior murals");

            extmu = Convert.ToInt32(Console.ReadLine());

            if (extmu < 0 || extmu > 30)

                Console.WriteLine("Enter a valid value between 0 to 30");

        } while (extmu < 0 || extmu > 30);

        //displaying the data

        Console.WriteLine("Revenue for the month of " + arr[month - 1]);

        Console.WriteLine("Number of interior murals : " + intmu);

        Console.WriteLine("Number of exterior murals : " + extmu);

        //calcultaing the total revenue

        total = (100 * intmu) + (200 * extmu);

        Console.WriteLine("Total Revenue : Rs " + total);

    }

}

Output:


Related Solutions

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...
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...
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
Create an C# application named ConvertMilesToKilometers whose Main() method prompts a user for a number of...
Create an C# application named ConvertMilesToKilometers whose Main() method prompts a user for a number of miles, passes the value to a method that converts the value to kilometers, and then returns the value to the Main() method where it is displayed.
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. -   ...
You are required to write an interactive JS program that prompts the user for three numbers...
You are required to write an interactive JS program that prompts the user for three numbers and then finds the sum, average, smallest, and the largest value of the numbers and prints the results labeling properly.
You are required to write an interactive program that prompts the user for ten (10) real...
You are required to write an interactive program that prompts the user for ten (10) real numbers and performs the following tasks: Reads and stores the numbers into one-dimensional array called A. The program must use a function to perform this task. Prints the content of the array. Write a function to perform this task. Calculates the sum of the numbers. Use a function to perform this task. Find the average of the numbers. Utilize a function to perform this...
You are required to write an interactive program that prompts the user for seven (7) real...
You are required to write an interactive program that prompts the user for seven (7) real numbers and performs the following tasks: Reads and stores the numbers into one-dimensional array called A. Calculates the sum of the numbers. Find the average of the numbers. Finds the smallest value of the numbers. Prints all the results with proper headings. Program requirements: -     The program must contain at least five functions using necessary parameters. These functions should read the data, perform the...
In the book "The Shifts and the Shocks" by Martin Wolf, of Chapter 4 How did...
In the book "The Shifts and the Shocks" by Martin Wolf, of Chapter 4 How did finance become fragile? What was the reason?
Java Program General Scenario: You are creating an interactive application that gets input from the keyboard...
Java Program General Scenario: You are creating an interactive application that gets input from the keyboard and keeps track of a grocery store that a businessman runs. In order to develop this application, you will be using 2 interfaces, 1 abstract class, and 1 concrete class. You should use the interfaces and the abstract class to create the concrete class. Your application should have overridden toString() at appropriate places so that you could display the object state, i.e., the string...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT