Question
programming problems
Chapter 4 Selection control structures 51 Chapter summary This chapter covered the selection control structure in detail. Descriptions and pseudo- examples were given for simple selection, null ELSE, combined IF and nested statements. Several solution algorithms that used the selection structure were The case structure was introduced as a means of expressing a linear nested iF statement in a simpler languages, and Programming problems Construct a solution algonthm for the folowing programming problems. Your solution a defining diagram a pseudocode algorithm .a desk check of the algorthm. 1 Design an algorithm that will receive two integer items from a terminal operator, and display to the screen their sum, difference, product and quotient. Note that the quotient calculation (first integer divided by second integer is only to be performecd if the second integer does not equal zero Design an algorithm that will read two numbers and an integer code from the screen The value of the integer code should be 1, 2, 3 or 4. If the value of the code is 1, compute the sum of the two numbers. If the code is 2, compute the difference (irst minus second). If the code is 3, compute the product of the two numbers. If the code is 4, and the second number is not zero, compute the quotient (first divided by second). If the code is not equal to 1, 2, 3 or 4, display an error message. The program is then to display the two numbers, the integer code and the computed result to the screen. 2 3 Design an algorithm that will prompt an operator for a student's serial number and the student's exam score out of 100. Your program is then to match the exam score to a letter grade and print the grade to the screen. Calculate the letter grade as follows: Assigned grade Exam score 90 and above 80-89 70-79 60-69 below 60
Explanation / Answer
Hi,
There are multiple questions in this, it is against chegg policy and we are not supposed to answer more than one question, please post others as separate question.
1 or 2- both are same infact.
defining diagram is a minimalistic view of what the algorithm does, it looks like below,
b. pseudo code
int a,b,code
print "enter numbers"
scan a and b
print enter intger code
scan code
if code is 1: print a+b
else if code is 2 print a-b
else if code is 3 print a*b
else if code is 4 and b!=0 print a/b
else print integer code type
this is the pseudo code, we are first prompting and taking inputs and displaying results accordingly
c. desk check is the manual iteration of algotithm
for ex: if
2
3
1
is entered
a=2
b=3
c=1
i.e print a+b=2+3=5
Thumbs up if this was helpful, otherwise let me know in comments
input processing output 2 integers a,b
integer code c prompt for a an b
get a and b
prompt for integer code
get code
perform operation on a and b according to value in code numbers a and b a, the, code entered and the result of the operation