Question

In: Computer Science

In this lab, I want you to take in a numeric grade as an integer and...

In this lab, I want you to take in a numeric grade as an integer and then print a letter grade per the table below:

90 or above is an A

80 or above is a B

70 or above is a C

60 or above is a D

Below a 60 is an F

You must use a branching statement that prints the appropriate letter grade based on the user input2. Please comment your code

Solutions

Expert Solution

Code is as follows as per the problem statement:

#include <iostream>

using namespace std;

int main() {
    int grade=0;
    cout<<"Enter the grade(number) : "; //marks secured is given as an input to the program
    cin>>grade;
    if (grade>=90)                      //condition check for giving A grade
        cout<<"\n Grade Secured is A";
    else if(grade>=80)                  //condition check for giving B grade
        cout<<"\n Grade Secured is B";
    else if(grade>=70)                  //condition check for giving C grade
        cout<<"\n Grade Secured is C";
    else if(grade>=60)                  //condition check for giving D grade
        cout<<"\n Grade Secured is D";
    else
        cout<<"\n Grade Secured is F";  //if the above conditions fail then give grade as F
    return 0;
}

Dear Student, As you have not mentioned the programmming language to be used for the problem statement, I have given the answer in C++ as it is widely acceptable.

Explanation:

  • First we give the marks secured by a student as an input to the program as the standard input.
  • We have used the variable "grade" for the purpose of storing the input marks given.
  • Then we check the condition as per the given rules via if else statements (conditional branching)
  • The correct alphabetical grade is printed on the output screen according to the conditions.

Keep Learning!


Related Solutions

what is accounting ? I want in numeric defintion. Please write only if you know. otherwise...
what is accounting ? I want in numeric defintion. Please write only if you know. otherwise please pass to other expert. If it is wrrong i will downvote . Plase dont copy pas chegg answers
I want you guys to rewrite this lab procedure, and it is fine if it was...
I want you guys to rewrite this lab procedure, and it is fine if it was shorter than this. An air track was fitted with two photocell bridges, one on each side of the collision region. Each bridge was operating in a gate mode timer that allows the collection of time intervals before and after collision. To ensure that friction and gravity have minimal effects, the track was leveled. Before starting the experiment, we ensured that loss in velocity was...
In this lab we will write 3 functions: GenData: This function will take an integer parameter...
In this lab we will write 3 functions: GenData: This function will take an integer parameter and return a vector with that many random integers generated in the range of 0 and 100 (rand()%101). Seed the random number generator with 22. Mean(): This function will take a vector and return the mean. Variance(): This function will take a vector and return the population variance, as: [Sum for values[( x_i - Mean )^2]] / (number of items) In Main: Use GenData...
This is for the lab practical I take on Tuesday night. If you could answer each...
This is for the lab practical I take on Tuesday night. If you could answer each one and show your work/ explain that'd be amazing so I can do well on the actual practical on Tuesday! Thank you! Chemistry 211   Lab Final Study Guide   Spring 2015 Useful Information: 1 ampere =coulomb/sec Faraday’s constant = 96,500 coulombs/mole of electrons Molar mass of Au = 197.0 g/mole, Molar mass of Cu = 63.55 g/mole m = moles ,   '   ’ c   kg...
TrackMinMax i want the generic version based on java For this lab, you will create a...
TrackMinMax i want the generic version based on java For this lab, you will create a generic version of the IntTrackMinMax class you wrote in a previous lab, called TrackMinMax. The API is: Function Signature Description constructor TrackMinMax() constructor check void check(T i) compares i to the current minimum and maximum values and updates them accordingly getMin T getMin() returns the minimum value provided to check() so far getMax T getMax() returns the maximum value provided to check() so far...
Lab 02 Final Grade Calculator **** I need it in JAVA **** **** write comments with...
Lab 02 Final Grade Calculator **** I need it in JAVA **** **** write comments with the code **** Objective: Write a program that calculates a final grade! The program should read in a file and then calculates the final grade based on those scores. Files read into this system are expected to follow this format: <Section0>\n <Grade0 for Section0>\n <Grade1 for Section0>\n … <GradeX for Section0>\n <Section1>\n <Grade0 for Section1>\n … <GradeY for Section1> <Section2> … <SectionZ> Sections denote...
Create a script that take a directory path from the user. What I want you to...
Create a script that take a directory path from the user. What I want you to do is figure out the total size of all files in the directory. You will need to import the os module for this. dirs=os.listdir(DIRECTORY) where DIRECTORY is the direction you want to look at will return a list of all files in that directory. You can then use a for loop to go through dirs much like you went through a range in the...
C language problem. Suppose I open I file and read a integer 24. And I want...
C language problem. Suppose I open I file and read a integer 24. And I want to store them into a array byte []. The answer should be byte[0] = 0x9F. How can I do that?
Hi! I am working on a lab for Organic Chemistry and I want to make sure...
Hi! I am working on a lab for Organic Chemistry and I want to make sure my answers are correct before submitting it! Thank you in advance! Stereoisomerism: A Model Exercise In this experiment you will construct models with your molecular model set that illustrate the concepts of chirality, chiral center (stereogenic center, asymmetric carbon atom), enantiomers, diastereomers, and meso forms. You will also learn about two conventions, R-S and Fischer, for designating the configurations of chiral molecules. You will...
Write a function that takes a numeric or integer vector and adds up only the numbers...
Write a function that takes a numeric or integer vector and adds up only the numbers whose integer parts are even. Modify your answer to question above to include an option that allows you to choose whether to sum numbers whose integer parts are even or are odd. Your function should have as a default that it gives the same output as the function in question 4. In other words, if the user doesn’t specify whether to sum evens or...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT