Question: post a brief description of a problem which to program a solution would require complex decisions (a decision required to test more than one condition)

post a brief description of a problem which to program a solution would require complex decisions (a decision required to test more than one condition) and/or loops. Provide a code snippet under your description which implements a solution using the most appropriate Java constructs.
please see similar example:
A particular clothes washing machine main control can instruct the machine to perform different tasks which include Off, Normal Wash, Delicate Wash, Rinse, and Spin. One way to process this is below:
switch (WashMachineCmd) {
case OffCmd:
{ /* Turn the washing machine off. Dont care about previous state. */
currentState = OFF;
break; }
case NormalWash:
{ /* Start Normal wash cycle. */
If (previousState == OFF) {
currentState = NORMAL_WASH; }
else {
System.out.println(ERROR: Cannot do Normal Wash from + displayState(previousState) + .);
}
break; }
case DelicateWash:
{ /* Start Delicate wash cycle. */
If (previousState == OFF) {
currentState = DELICATE_WASH; }
else {
System.out.println(ERROR: Cannot do Delicate Wash from + displayState(previousState) + .);
}
break; }
case Rinse:
{ /* Start Rinse cycle. */
If ((previousState == NORMAL_WASH) || previousState == DELICATE_WASH) {
currentState = RINSE; }
else
{
System.out.println(ERROR: Cannot do Delicate Wash from +
displayState(previousState) + .); }
break; }
case Spin:
{ /* Start Spin cycle. */
If (previousState == RINSE) {
currentState = SPIN; }
else {
System.out.println(ERROR: Cannot do Delicate Wash from + displayState(previousState) + .);
}
break; }
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!