Ex:- If the User Input B+ , the Program Should Output 87-89

Ex:- If the User Input B+ , the Program Should Output 87-89

  1. Write a pseudo code to display the score range for each letter grade, when the user inputs a letter grade. The program will only run once and at first the program must display a message asking the user to input the desired letter grade. Please check the course web page to find the score ranges for each letter grade.

Ex:- if the user input “B+”, the program should output “87-89”

If the user input “A” the program should output “90-100”

If the user input an invalid letter grade, for example “M”, the program should display an error message

Sample Solution

PROGRAM ShowScoreRange

Write “Please input the Letter Grade”

Read LetterGrade

Set ScoreRange to “90-100”

IF (grade == “A”)

Set ScoreRange to “90-100”

ELSE IF (grade == “B+”)

Set ScoreRange to “87-89”

ELSE IF (grade == “B”)

Set ScoreRange to “80-86”

ELSE IF (grade == “C+”)

Set ScoreRange to “77-79”

ELSE IF (grade == “C”)

Set ScoreRange to “70-76”

ELSE IF (grade == “D+”)

Set ScoreRange to “67-69”

ELSE IF (grade == “D”)

Set ScoreRange to “60-66”

ELSE IF (grade == “F”)

Set ScoreRange to “0-60”

ELSE

Write “Invalid Letter Grade!”

EXIT PROGRAM

Write “Score range is ”, ScoreRange

  1. Write a pseudocodefor a program to find the maximum number from a sequence of numbers input by the user. The program should first ask the user, how many numbers it should expect? Once the user enters that value, the program should accept the sequence of numbers that equal to the expected number count. Finally it must display the maximum number out of that sequence of numbers input by the user.(hint: use while loop).

PROGRAM MaxFinder

WRITE “How many numbers do you want to enter ?”

Read count

Set index to 1

WRITE “Please enter the number”

READ number

Set max to number

WHILE (index < count)

WRITE “Please enter the number”

READ number

IF (max < number)

Set max to number

Set index to index + 1

WRITE “Maximum Number is ”, max

  1. Write the pseudocode for a program that takes two separate inputs from the user and saves them in the dividend and divisor variables. It then checks to be sure that the divisor is not 0, and prints up the dividend divided by the divisor if that is true, and prints “Can’t divide by zero” if it is not.

PROGRAM DivisorChecker

WRITE “Please enter the divident”

READ dividend

WRITE “Please enter the divisor”

READ divisor

Set answer to 0

IF (divisor != 0)

Set answer to dividend / divisor

WRITE answer

ELSE

WRITE “Can’t divide by zero”

  1. Write the pseudocode for a program that would find the average of 3 numbers. The program must ask for the 3 numbers from the user and once all 3 numbers are entered, the program must display the average of those 3 numbers.

PROGRAM AvgCalculator

WRITE “Please enter the number”

READ num1

WRITE “Please enter the number”

READ num2

WRITE “Please enter the number”

READ num3

Set avg to (num1 + num2 + num3) / 3

WRITE “Average is ”, avg

  1. Write a program in pseudocode that reads in three values and writes out the result of subtracting the second value from the sum of the first and third values.

PROGRAM AvgCalculator

WRITE “Please enter the number”

READ num1

WRITE “Please enter the number”

READ num2

WRITE “Please enter the number”

READ num3

Set sum to num1 + num3 – num2

WRITE “Sum is ”, sum

  1. Write a program in pseudocode to get 3 integers from the user and print them in numeric order.

PROGRAM ThreeNumberSorter

WRITE “Please enter the number”

READ num1

WRITE “Please enter the number”

READ num2

WRITE “Please enter the number”

READ num3

IF (num1 >= num2)

IF (num3 >= num1)

WRITE num3, “ ”, num1, “ “, num2

ELSE IF (num1 num3 & num3 > num2)

WRITE num1, “ ”, num3, “ “, num2

ELSE

WRITE num1, “ ”, num2, “ “, num3

ELSE

IF (num3 >= num2)

WRITE num3, “ ”, num2, “ “, num1

ELSE IF (num2 > num3 & num3 > num1)

WRITE num2, “ ”, num3, “ “, num1

ELSE

WRITE num2, “ ”, num1, “ “, num3