Question

Set up four different algorithms and flowcharts for calculating a student’s letter grade given the following...

Set up four different algorithms and flowcharts for calculating a student’s letter grade given the following (do not use straight-through logic):

90-100 = A

80-89 = B

70-79 = C

60-69 = D

below 60 = F

Which of the four solutions would be the best? Justify your answer.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1st algorithm:


1.Start
2.get input marks.
3.if(marks>=90&&marks<=100) make grade='A'
else if(marks>=80&&marks<=89) make grade='B'
else if(marks>=70&&marks<=79) make grade='C'
else if(marks>=60&&marks<=69) make grade='D'
else if(marks<60) make grade='F'
4.print grade.
5.Stop.

1st Program:

#include<stdio.h>
void main()
{
    int marks;
    char grade;
    printf("Enter marks:");
    scanf("%d",&marks);
    a= marks/10;
    if(marks>=90&&marks<=100)
        grade='A';
    else if(marks>=80&&marks<=89)
        grade='B';
    else if(marks>=70&&marks<=79)
        grade='C';
    else if(marks>=60&&marks<=69)
        grade='D';
    else if(marks<60)
        grade='F';
printf("your grade is: %c\n",grade);
}

Output:

Flow Chart:

2nd algorithm:

1.Start
2.get input marks.
3.initialize a = marks/10.
4.if(a==9||a==10) make grade='A';
else if(a==8) make grade='B';
else if(a==7) make grade='C';
else if(a==6) make grade='D';
else if(a<6) make grade='F';
5.print grade.
6.Stop.

2nd Program:
#include<stdio.h>
void main()
{
    int marks;
    int a ;
    printf("Enter marks:");
    scanf("%d",&marks);
   a = marks/10;
   if(a==9||a==10)
        grade='A';
    else if(a==8)
        grade='B';
    else if(a==7)
        grade='C';
    else if(a==6)
        grade='D';
    else if(a<6)
        grade='F';
printf("your grade is: %c\n",grade);
}

flowchart:

3rd algorithm:

1.Start
2.get input marks.
3.switch(marks)
   case 90 ... 100:    grade='A';break;

   case 80 ... 89:       grade='B';break;

   case 70 ... 79:       grade='C';break;

   case 60 ... 69:       grade='D';break;

   case 0 ... 59:       grade='E';break;
4.print grade.
5.Stop.

3rd Program:

#include<stdio.h>
void main()
{
    int marks;
    char grade;
    printf("Enter marks:");
    scanf("%d",&marks);
    switch(marks)
        {
        case 90 ... 100:
            grade='A';
            break;
  
        case 80 ... 89:
            grade='B';
            break;
  
        case 70 ... 79:
            grade='C';
            break;
  
        case 60 ... 69:
            grade='D';
            break;
  
        case 0 ... 59:
            grade='E';
            break;
  
        default:
            printf("wrong marks \n");
  
        }
printf("your grade is: %c\n",grade);
}
4th algorithm:

1.Start
2.get input marks.
3.use ternary operator for assigning grade.
(marks>=90&&marks<=100)?grade='A':((marks>=80&&marks<=89)?grade='B':((marks>=70&&marks<=79)?grade='C':((marks>=60&&marks<=69)?grade='D':((marks<=59)?grade='F':(printf("wrong marks \n"))))))

4.print grade.
5.Stop.

4th Program:

void main()
{
    int marks;
    char grade;
    printf("Enter marks:");
    scanf("%d",&marks);
(marks>=90&&marks<=100)?grade='A':((marks>=80&&marks<=89)?grade='B':((marks>=70&&marks<=79)?grade='C':((marks>=60&&marks<=69)?grade='D':((marks<=59)?grade='F':(printf("wrong marks \n"))))));
printf("your grade is: %c\n",grade);
}

In the above 4 methods used the method using switch statement is the best way to assign grade.

Add a comment
Know the answer?
Add Answer to:
Set up four different algorithms and flowcharts for calculating a student’s letter grade given the following...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C ++ . In professor Maximillian’s course, each student takes four exams. A student’s letter grade...

    C ++ . In professor Maximillian’s course, each student takes four exams. A student’s letter grade is determined by first calculating her weighted average as follows:                                                 (score1 + score2 + score3 + score4 + max_score) weighted_average = -----------------------------------------------------------------------                                                                                                 5 This counts her maximum score twice as much as each of the other scores. Her letter grade is then a A if weighted average is at least 90, a B if weighted average is at least 80...

  • Part II: Problem Solving (20 points) Develop a solution for the problem below from the textbook....

    Part II: Problem Solving (20 points) Develop a solution for the problem below from the textbook. Your solution must include: PAC (5 points) Algorithm (15 points) Write an algorithm for calculating ta student’s letter grade given the numeric grade based on the following categories. A: numeric grade between 90 & 100, inclusive. (90 is considered an A) B: numeric grade between 80 & 89 C: numeric grade between 70 & 79 D: numeric grade between 60 & 69 F: numeric...

  • Create a MIPS program that does the following: 4. Determine the letter grade a. Use the...

    Create a MIPS program that does the following: 4. Determine the letter grade a. Use the floating point calculated average to determine the letter grade. You will need to research the instructions to use to do comparisons with floating point numbers. (see Course Resources) b. Use the following chart: 90 - 100 80 - 89 70 - 79 ............. 60 - 69.............. <60 ..................... ............... 5. Display a message and the letter grade. 6. Your output should look similar to...

  • 1. Create a program that takes a numerical score and outputs a letter grade. 2. In...

    1. Create a program that takes a numerical score and outputs a letter grade. 2. In this program, create two void functions titled makeScore and theGrade with an int argument. 3. The function makeScore should have a Reference parameter and theGrade should have a Value parameter. Note: Specific numerical scores and letter grades are listed below: 90-100 = Grade A 80-89 = Grade B 70-79 = Grade C 60-69 = Grade D 0-59 = Grade F 4. The function makeScore...

  • A web page displays an input box that a user can use to a enter a...

    A web page displays an input box that a user can use to a enter a grade from a test and a button that when pressed tells the user what letter grade they received for that test. Assume that the grade is stored in an integer named grade and you will put the letter grade in to a string variable named letter. Write one or more if-statements in Javascript that will set the correct value into letter assuming the standard...

  • Use PHP to perform the following operations: 1. define an array having at least 20 elements...

    Use PHP to perform the following operations: 1. define an array having at least 20 elements representing the grade of some students, i.e., 0<=$grade[i]<=100. 2. find out the length of the array 3. use switch to work on each element, converting a numeric grade to a letter grade and print the letter grade. The rules are below: A 90 - 100 B 80 - 89 C 70 - 79 D 60 - 69 F 0 - 59

  • Write a C++ program that will provide a user with a grade range if they enter...

    Write a C++ program that will provide a user with a grade range if they enter a letter grade. Your program should contain one function. Your function will accept one argument of type char and will not return anything (the return type will be void), but rather print statements to the console. Your main function will contain code to prompt the user to enter a letter grade. It will pass the letter grade entered by the user to your function....

  • Please write in MATLAB code: 1. Write a function called myMin4 that will take in four...

    Please write in MATLAB code: 1. Write a function called myMin4 that will take in four numbers and returns the minimum value. You may NOT use the built-in min() function. Run the function for the following: myMin4(4, 8, 12, 15) myMin4(18, 9, 1, 6) myMin4(8, -2, 2, 10) 2.   Write a function called classAverage that takes in an array of numbers and returns the letter grade of the class average. The grade ranges are as follow: Average >90 = A...

  • Microsoft Excel Question. I'm having trouble using the vlookup function, I have calculated a final numerical...

    Microsoft Excel Question. I'm having trouble using the vlookup function, I have calculated a final numerical grade for a hypothetical course, and and trying to use a set of numerical grades with their corresponding letter grades to get a vlookup function to return the letter grade from the numerical grade. However the function for some reason only returns the lowest value out of the set grades, not the closest match. Projects Classwork Teamwork/Integrity 100 100 A+ 98 A+ 97 A...

  • Python: Create a simple program that calls a function call gradeCalculated, in the main area the...

    Python: Create a simple program that calls a function call gradeCalculated, in the main area the user is asked to enter their grade from 0-100. Pass in the number grade via a parameter into the function, based on their grade tell the user what letter grade they got as a letter grade and number and then tell me a quote how you feel about your grade. 90+ A 80-89 B 70-79 C 60-69 D Below 60 F

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT