Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Chapter 2, you created an interactive application named MarshallsRevenue, and

ID: 3908415 • Letter: I

Question

In Chapter 2, you created an interactive application named MarshallsRevenue,
and in Chapter 3 you created a GUI version of the application named
MarshallsRevenueGUI. The programs prompt 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 applications
also display the total expected revenue and a statement that indicates whether more
interior murals are scheduled than exterior ones. Now, modify one or both of the
applications 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.
Copyright

In Chapter 4, 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.
Copyright

In previous chapters, you created applications for Marshall’s Murals. Now, modify the
version of the MarshallsRevenue program created in Chapter 5 so that after mural
data entry is complete, the user is prompted for the appropriate number of customer
names for both the interior and exterior murals and a code for each that indicates the
mural style: L for landscape, S for seascape, A for abstract, C for children’s, or O for
other. When a code is invalid, reprompt the user for a valid code continuously. After
data entry is complete, display a count of each type of mural. Then, continuously
prompt the user for a mural style code until the user enters a sentinel value. With each
code entry, display a list of all the customers with that code and whether their mural is
interior or exterior. If the requested code is invalid, display an appropriate message and
reprompt the user.

In previous chapters, you continued to modify the MarshallsRevenue program. Now,
modify the program so that the major functions appear in the following individual
methods:
•• A method that prompts for and returns the month
•• A method that prompts for and returns the number of murals scheduled and is
called twice—once for interior murals and once for exterior murals
•• A method that accepts the number of interior and exterior murals scheduled,
accepts the month they are scheduled, displays the interior and exterior prices, and
then returns the total expected revenue
•• A method that fills an array with customer names and mural codes and is called
twice—once to fill the array of interior murals and once to fill the array of exterior
murals
•• A method that continuously prompts for mural codes and displays jobs of the
corresponding type until a sentinel value is entered.

Explanation / Answer

Code:

import java.util.*;

class MarshallRevneue

{

Scanner sc = new Scanner(System.in);

int exter_mur_price = 750;

int inter_mur_price = 500;

String inter_mur_cust[];

char inter_mur_code[];

String exter_mur_cust[];

char exter_mur_code[];

int getMonth()

{

int month = 0;

do

{

System.out.println("Enter the Month Value in the range if 1 to 12");

month = sc.nextInt();

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

return month;

}

int getMurals()

{

int mur = 0;

do

{

System.out.println("enter the number of murals scheduled to be painted");

mur = sc.nextInt();

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

return mur;

}

int computeRevenue(int month, int inter_mur, int exter_mur)

{

if(month== 12 || month == 1 || month == 2)

{

exter_mur = 0;

}

if(month == 4 || month == 5 || month == 9 || month == 10)

{

exter_mur_price = 699;

}

if(month == 7 || month == 8)

{

inter_mur_price = 450;

}

int Revenue = inter_mur_price* inter_mur + exter_mur_price * exter_mur ;

System.out.println("price for interior murals for this months" + inter_mur_price);

System.out.println("price for exterior murals for this months" + exter_mur_price);

  

return Revenue;

}

void getnamesandcodes(int murals, String type)

{

if(type.equals("exterior"))

{  

inter_mur_cust = new String[murals];

inter_mur_code = new char[murals];

char c;

for(int i = 0;i<murals;i++)

{

System.out.println("Enter name of the customer" + (i+1)+ ": ");

String s = sc.nextLine();

do

{

System.out.println("Enter the code of his/her mural style: " );

c = sc.nextLine().charAt(0);

}while(c != 'L' && c != 'S' && c != 'A' && c != 'C'&& c != 'O');

inter_mur_cust[i] = s;

inter_mur_code[i] = c;

}

}

else

{

exter_mur_cust = new String[murals];

exter_mur_code = new char[murals];

char c;

String gb = sc.nextLine();

for(int i = 0;i<murals;i++)

{

System.out.println("Enter name of the customer" + (i+1) +":");

String s = sc.nextLine();

do

{

System.out.println("Enter the code of his/her mural style: " );

c = sc.nextLine().charAt(0);

}while(c != 'L' && c != 'S' && c != 'A' && c != 'C'&& c != 'O');

exter_mur_cust[i] = s;

exter_mur_code[i] = c;

}

}

}

void getJobs()

{

while(true)

{

char c;

do

{

System.out.println("Enter the code of Mural Style to display jobs : " );

c = sc.nextLine().charAt(0);

}while(c != 'L' && c != 'S' && c != 'A' && c != 'C'&& c != 'O');

for(int i = 0;i<inter_mur_code.length;i++)

{

if(inter_mur_code[i] == c)

{

System.out.println(inter_mur_cust[i] + " interior");

}

}

for(int i = 0;i<exter_mur_code.length;i++)

{

if(exter_mur_code[i] == c)

{

System.out.println(exter_mur_cust[i] + " exterior");

}

}

}

}

}

class Main {

public static void main(String[] args) {

MarshallRevneue mr = new MarshallRevneue();

System.out.println("for interior murals");

int inter_mur = mr.getMurals();

System.out.println("for exterior murals");

int exter_mur = mr.getMurals();

int month = mr.getMonth();

  

System.out.println("Total Expected Revenue is : " + mr.computeRevenue(month, inter_mur, exter_mur));

  

System.out.println("Enter the names of the customer for interior murals");

mr.getnamesandcodes(inter_mur, "interior");

System.out.println("Enter the names of the customer for exterior murals");

mr.getnamesandcodes(exter_mur, "exterior");

mr.getJobs();

  

}

}