Question

The CASE structure is a selection structure, however not all selection structures may be represented as...

The CASE structure is a selection structure, however not all selection structures may be represented as CASE. Give an example of a selection problem that may be solved using the CASE structure and another selection problem that CANNOT be represented by the CASE structure.

Type your response in the space provided (after you have created a thread).

Indicate which problem CAN and CANNOT be represented by CASE

Provide an explanation of why each of your suggested problems fits the appropriate category.

Homework Answers

Answer #1

Case selection structures are a substitute for long if statements that compare a variable to several integral values. This statement is used when we have to select one choice from multiple choices on the basis of the value of some variable.

Flow chart for CASE structure:-

Example of problem that can be solved using case:-

Display a message for every value in a dice . In this example variable dice is being compared to 6 different intergers values therefore it can easily be done using CASE selection structure .

switch (dice)
{
case 1: cout << "one"; break;
case 2: cout << "two"; break;
case 3: cout << "three"; break;
case 4: cout << "four"; break;
case 5: cout << "five"; break;
case 6: cout << "six"; break;
default: cout << "ERROR"; break;
}

  • CASE cannot be used with float constant
  • Cannot use the variable expression in case.
  • Cannot use CASE for a range of values

Example of problem that cannot be solved using case:-

Display the division of student based on his percentage .

marks<33 : divison 3

marks >75 -1st division

50<marks<75 - 2nd division

33<marks<50 3rd divison

marks<33 -FAIL

This example includes comaprision of variable marks in a range of integer value(for example:- 0 to 33, 33 to 50 etc) therefore it cannot be solved using CASE selection structure.

I tried up making a similar program with just two cases using CASE to show you the error given by the compiler. Screenshot of that code is given below.

********************** Feel free to leave a comment in case of any doubt*************************

Know the answer?
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
Similar Questions
For each case below, list the assumptions that are applicable. Indicate which of (a) continuity equation,...
For each case below, list the assumptions that are applicable. Indicate which of (a) continuity equation, (b) Euler’s equation, (c) Bernoulli’s equation, (d) energy equation, (e) isentropic relations, and/or (f) equation of state would be most appropriate to use to find the discharge velocity (more than one may apply). Defend your choice(s) by explaining how each equation fits the assumptions stated and how each would be used to solve the problem. Only include the information requested—do not attempt to solve...
Case Challenge #1 (Please do not attempt to solve if you can not answer all) A...
Case Challenge #1 (Please do not attempt to solve if you can not answer all) A New, Dynamic Industry THE ENERGY BAR INDUSTRY In 1986, PowerBar, a firm in Berkeley, California, single-handedly created the energy bar category. Positioned as an athletic energy food, it was distributed at bike shops and events that usually involved running or biking. The target segment was the athlete who needed an efficient, effective energy source. Six years later, seeking to provide an alternative to the...
CASE # 1 (Managing without Managers) Just Music, a European commercial music service, is synonymous with...
CASE # 1 (Managing without Managers) Just Music, a European commercial music service, is synonymous with dramatically changing the way consumers access and use music on a day-to-day basis. They have succeeded in moving consumers away from buying music and, instead, moving them towards a model of renting the music they enjoy for a monthly fee. The European music giant, launched in 2008, was developed into the business we know today by European entrepreneur Paul Moon, who was inspired to...
1. The Hypothetical Method Hypothetical reasoning attempts to provide explanations for unexplained phenomena. In using this...
1. The Hypothetical Method Hypothetical reasoning attempts to provide explanations for unexplained phenomena. In using this kind of reasoning, scientists formulate hypotheses—what you might call "rational guesses"—that apply the available information to formulate a possible explanation for something that has been observed. The four stages of the hypothetical method are as follows: 1. A problem or mystery is identified. 2. A hypothesis—a tentative explanation for the problem—is formulated. 3. The implications of the hypothesis are drawn. This means that scientists...
Item 6 In the case below, the original source material is given along with a sample...
Item 6 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version The theory we have constructed originates with the three phases of learning described above. We have organize and adapted the features of simulations to provide the learner with the most effective and efficient presentations in order to achieve successful acquisition, application and assessment. Our general...
Outline and answer all discussion questions following case description in details. (Do not attempt to solve...
Outline and answer all discussion questions following case description in details. (Do not attempt to solve if you can not fulfill all the requirements!!!!) THE ENERGY BAR INDUSTRY In 1986, PowerBar, a firm in Berkeley, California, single-handedly created the energy bar category. Positioned as an athletic energy food, it was distributed at bike shops and events that usually involved running or biking. The target segment was the athlete who needed an efficient, effective energy source. Six years later, seeking to...
Item 1 In the case below, the original source material is given along with a sample...
Item 1 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version I accept the point that whenever learning occurs, some medium or mix of media must be present to deliver instruction. However, if learning occurs as a result of exposure to any media, the learning is caused by the instructional method embedded in the media presentation....
Based on the Case below, Write a brief explanation that explains why the case represents its...
Based on the Case below, Write a brief explanation that explains why the case represents its particular ACHE competency domain. (Be sure that the explanation justifies the assigned competency domain based upon the facts and circumstances of the case.) Case: Case 4: Knowledge of the Healthcare Environment A new administrator in a large suburban healthcare system was hired to work in the corporate offices as a patient service coordinator for the five hospitals, one rehabilitation hospital and one skilled nursing...
drwxr-xr-x 10 mst staff 320 Sep 18 14:58 Sites drwxr-xr-x 2 mst staff 64 May 28...
drwxr-xr-x 10 mst staff 320 Sep 18 14:58 Sites drwxr-xr-x 2 mst staff 64 May 28 2017 VirtualBox VMs -rw-r--r-- 1 mst staff 633 Dec 11 2019 balance.pl drwxr-xr-x 4 mst staff 128 Oct 11 2014 bin -rw-r--r-- 1 mst staff 473 Dec 13 2019 bitshift.py For this problem, we are mainly concerned with the set of access permissions, which appears at the beginning of the line for each file or directory. Directories have a "d" at the beginning of...
Item 1 In the case below, the original source material is given along with a sample...
Item 1 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version When instructors are creating discussion board activities for online courses, at least two questions must be answered. First, what is the objective of the discussions? Different objectives might be to create a "social presence" among students so that they do not feel isolated, to ask...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT