Question

In: Computer Science

Write pseudocode (3 Marks) and program structure (4 Marks) for the problem given below; In a...

  1. Write pseudocode and program structure (4 Marks) for the problem given below;

In a college, students are awarded a pass grade if their total mark is between 50-59, credit grade if the mark is between 60-69, distinction for marks between 70-79. High distinction if the mark is above or equal to 80 and fail if the mark is below 50.

Solutions

Expert Solution

The Pseudocode for above problem :

NOTE: The input must be in range 0-100 or else unexpected output will be thrown by program.

ALGORITHM (PSEUDOCODE)
Get MARKS from input

function (MARKS)

        if MARKS >= 80 do
                GRADE = "High Distinction"
        else if MARKS >= 70 do
                GRADE = "Distinction"
        else if MARKS >= 60 do
                GRADE = "Credit"
        else if MARKS >= 50 do
                GRADE = "Pass"
        else do
                GRADE = "Fail"

return GRADE

The solution (program structure) in C (since no language is provided):

#include <stdio.h>  // used for functions like scanf anf printf
#include <stdlib.h>       // used for malloc function to allocate memory.

char* function(int Marks);      // function declaration here

// main function where execution starts.
int main()
{
        int Marks;      // integer variable to store marks from user input
        printf("Marks: ");      // outputs text before taking marks.
        scanf("%d", &Marks);        // takes input and stores in variable

        char *grade = function(Marks);  // function called to get grade evaluated and stored in pointer

        printf("Grade: %s\n", grade);   // prints grade on output screen

        return 0;       // program ends here
}

char* function(int Marks)       // function defination, control comes here when function is called
{
        char *grade = malloc(sizeof(char)*20);  // memory allocated to store grade.

        // if-else statements to calculate grade according to range.
        if (Marks >= 80)     // range: 80-100
                grade = "High Distinction";
        else if (Marks >= 70)        // range: 70-80
                grade = "Distinction";
        else if (Marks >= 60)        // range: 60-70
                grade = "Credit";
        else if (Marks >= 50)        // range: 50-60
                grade = "Pass";
        else                                    // range: 0-50
                grade = "Fail";

        return grade;   // returns grade to main function.
}

Code Screenshot for Indentation:

Sample Output:

Hope it helps.


Related Solutions

C Program and pseudocode for this problem. Write a C program that plays the game of...
C Program and pseudocode for this problem. Write a C program that plays the game of "Guess the number" as the following: Your program choose the number to be guessed by selecting an integer at random in the rang of 1 to 1000. The program then asks the use to guess the number. If the player's guess is incorrect, your program should loop until the player finally gets the number right. Your program keeps telling the player "Too High" or...
Problem 1: (10 marks) ALGORITHM COMPLEXITY:Write an algorithm (pseudocode but not a program) that takes a...
Problem 1: ALGORITHM COMPLEXITY:Write an algorithm (pseudocode but not a program) that takes a positive numberias an input, where i=a1a2...an,n>=3(numberwith 3 or more digits, every digit can have the value between 0 and 9–both inclusive). The algorithm should find the largest number jsuch that j=b1..bm, 1<=m<=n(numberwith m digits),andevery bk<=bk+1where1<=k<m and bk,bk+1ε{a1, a2, an}.Also, perform the computational complexity (time complexity)analysis of your algorithm and write the algorithm complexity in Big-Oh notation. Examples:Input: 23720, Output: 237Input: 9871, Output: 9Input: 1789, Output:1789Input: 2372891,...
4. Write out the pseudocode for when Merge-Sort is stable based on the information given below:...
4. Write out the pseudocode for when Merge-Sort is stable based on the information given below: Comparision Based Stable Sorts such as Merge Sort maintain stability by ensuring that Element A[ j ] comes before A[ i ] if and only if A[ j ] < A[ i ], here i, j are indices and i < j. The relative order is preserved if A[ i ] comes before A[ j ]. Mergesort is stable, provided its implementation employs the...
4. Write a program trace for the pseudocode in Exercise • E4.6, assuming the input values...
4. Write a program trace for the pseudocode in Exercise • E4.6, assuming the input values are 4 7 –2 –5 0. Ans. first value minimum output • E4.6 --> This is the pseudocode Set a Boolean variable "first" to true. While another value has been read successfully If first is true Set the minimum to the value. Set first to false. Else if the value is less than the minimum Set the minimum to the value. Print the minimum.
write pseudocode for the following problems not c code Pseudocode only Write a C program to...
write pseudocode for the following problems not c code Pseudocode only Write a C program to print all natural numbers from 1 to n. - using while loop Write a C program to print all natural numbers in reverse (from n to 1). - using while loop Write a C program to print all alphabets from a to z. - using while loop Write a C program to print all even numbers between 1 to 100. - using while loop...
How do you write pseudocode for this problem? The decides are provided below. Problem Statement We...
How do you write pseudocode for this problem? The decides are provided below. Problem Statement We are going to create a game called TwentyOne, which is similar to the Blackjack and War card games. This game has a dealer/computer and 1-4 players, and the game will generate random numbers from 1 to 11 to simulate the values in cards. All players start with a specified amount of money, which they determine at the start of the game, and the goal...
Selection/Conditional Structure: Create a flowchart and pseudocode for the problem below: Juan dela Cruz Restaurant is...
Selection/Conditional Structure: Create a flowchart and pseudocode for the problem below: Juan dela Cruz Restaurant is offering a 20% discount to all customers whose last name is also dela Cruz. Input the last name of the customer and the total amount due to the customer and then output the amount to be paid. (C++ Program, choose only the LAST NAME)
Write and submit a test driver program employeeTest.java, the pseudocode is below. start instantiate a Employee...
Write and submit a test driver program employeeTest.java, the pseudocode is below. start instantiate a Employee object get input from user for worker name loop while user does not enter "" Set workers name get input from user for employeeId set workers employeeId get input from user for shift (day/night) set workers shift (input "day" = true , input "night" = false) get input from user workers hourly pay set workers hourly pay get input from user total hours worked...
Write program logic or pseudocode to create 3 small programs that do the following: The first...
Write program logic or pseudocode to create 3 small programs that do the following: The first should compute the sum of 2 given integers. The second should multiply the 2 integers. The third should triple the sum of the 2 integers.
Given the below pseudocode, write the proper code that implements it using MARIE's assembly language:               ...
Given the below pseudocode, write the proper code that implements it using MARIE's assembly language:                    Input a number and store it in X; if X > 1 then    Y := X + X;    X := 0; endif; Y := Y + 1; Output the value of Y; N.B: You should include the MARIE code in your Answer, with an explanation of each instruction in your code beside it. Example:              Subt One         /Subtract 1 from AC Add a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT