EXAMINE THE FF. CODE   int numValue =2; int answer =0; switch(numValue){ case 1: answer +=1; case 2: answer +=2; case 3: answer +=3;             break;

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 9RQ
icon
Related questions
Question

PART 1. EXAMINE THE FF. CODE

 

int numValue =2;

int answer =0;

switch(numValue){

case 1: answer +=1;

case 2: answer +=2;

case 3: answer +=3;

            break;

case 4: answer +=4;

case 5: answer +=5;

default: answer =0;

            break;

} cout <<”Answer: ” << answer << endl;

 

1. What is the answer(output) if the value of numValue is 22? ____________________

2. What is the answer(output)  if the value of numValue is 1? ____________________

3. What is the answer(output)  if the value of numValue is 4? ____________________

4. What is the answer(output)  if the value of numValue is 2? ____________________

5. Is break statement in the default case needed?  Why or why not? Explain.____________________

 

Part 2. Create a C++ program that will input student’s ID, scholarship code (“A/a-D/d”), units, tuition fee Per unit is 450php and total tuition after adding misc. fee of 1500php and lab fee of 900php and discount.

 

Scholarship Code                              Description                            Discount

E/e                                                      Regular                                   0%

D/d                                                     Non-Academic                       25%

C/c                                                      Department                           50%

B/b                                                     College                                    75%

A/a                                                      Presidential                           100%

 

Output their scholarship code and the net tuition fee.

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT