1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Assoli18 [71]
3 years ago
9

Rita is writing a C++ programe in whic, she wants to display the grades (stored in variable grade) as per the table of marks (st

ored in variable marks) given below: A – 90-100 B – 80-89 C – 70-79 D < 70
Computers and Technology
1 answer:
qwelly [4]3 years ago
7 0
#include <iostream>
#include <vector>
using namespace std;

class Student
{
public:    
    Student(int mark)    
    {        
        this->mark = mark;

        if (mark >= 90 && mark <= 100)
            grade = 'A';
        else if (mark >= 80 && mark <= 89)            
            grade = 'B';
        else if (mark >= 70 && mark <= 79)
            grade = 'C';
        else if (mark < 70 && mark >= 0)
            grade = 'D';
        else
            cout << "Invalid mark, grade not assigned";
    }

    int getMark()
    {
        return mark;
    }

    char getGrade()
    {
        return grade;
    }

private:
    int mark;
    char grade;
};

int main()
{
    vector<Student> students;
    int num, mark;

    cout << "Enter number of students: ";
    cin >> num;

    if (num <= 0)
        cout << "Invalid number of students, exiting";
    else
    {
        for (int i = 1; i <= num; i++)
        {
            cout << "Enter marks for student " << i << ": ";
            cin >> mark;

            Student s(mark);
            students.push_back(s);
        }
    }

    // do whatever you like with the vector from here onwards, such as:
    /*
    for (int i = 0; i < students.size(); i++)
    {
        cout << "Student " << i + 1 << " grade: " << students[i].getGrade() << endl;
    }
    */

    return 0;
}
You might be interested in
Please discuss what you consider to be some of the biggest challenges your company will face when working from the Linux command
Nastasia [14]

Answer:

Command remembering issues.

Explanation:

The biggest challenge my company will face when working on Linux is remembering issues of the commands. The commands in Linux are a bit difficult to remember as they are complicated bit but practice can solve this issue. "Practice makes a man perfect" this well known saying suggests that practice can make perfect and this well known saying also works with Linux the more practice the employees do the more perfect they get.

3 0
3 years ago
In the world of computers, the term ____ refers to the computerâs physical components, such as the monitor, keyboard, motherboar
USPshnik [31]
The missing word there is hardware
6 0
3 years ago
On an XBOX 360, what does it mean if you get 4 red rings on your console?
Hitman42 [59]

Answer:

C. This happened to me.

Explanation:

4 0
3 years ago
Write the code to produce a for loop that counts down from 20 to 0 by 2’s and prints the number each time it goes through the lo
yulyashka [42]

Explanation:

Count-controlled for loop (Three-expression for loop)

This is by far the most common type. This statement is the one used by C. The header of this kind of for loop consists of a three-parameter loop control expression. Generally it has the form:

for (A; Z; I)

A is the initialisation part, Z determines a termination expression and I is the counting expression, where the loop variable is incremented or dcremented. An example of this kind of loop is the for-loop of the programming language C:

for (i=0; i <= n; i++)

This kind of for loop is not implemented in Python!

Numeric Ranges

This kind of for loop is a simplification of the previous kind. It's a counting or enumerating loop. Starting with a start value and counting up to an end value, like for i = 1 to 100

Python doesn't use this either.

Vectorized for loops

They behave as if all iterations are executed in parallel. This means, for example, that all expressions on the right side of assignment statements get evaluated before the assignments.

Iterator-based for loop

Finally, we come to the one used by Python. This kind of a for loop iterates over an enumeration of a set of items. It is usually characterized by the use of an implicit or explicit iterator. In each iteration step a loop variable is set to a value in a sequence or other data collection. This kind of for loop is known in most Unix and Linux shells and it is the one which is implemented in Python.

Example of a simple for loop in Python:

>>> languages = ["C", "C++", "Perl", "Python"]  

>>> for x in languages:

...     print(x)

...  

C

C++

Perl

Python

>>>

3 0
2 years ago
Is the movie IT really that scary ? Rate between 1-10, 10 being I had nightmares
mezya [45]
5 I don’t think it’s good. I thought it was boring.
4 0
3 years ago
Other questions:
  • 14. Which commercial RDBMS product was the first to hit the market and is the biggest?
    15·1 answer
  • A ________ is a system of hardware and software that stores user data in many different geographical locations and makes that da
    14·1 answer
  • witch of the following is a good way to choose your location as you develop your study method? A. Going where most of your frien
    6·1 answer
  • Susan bought a new sweater on sale for $28.93.she was charged HST of 13%.find the total amount of her bill including taxes.​
    9·1 answer
  • Rob creates a Course_Details table that has four columns: Course _ID, Course_Name, Semester and Credits. A course may have 0.5 c
    6·2 answers
  • ______ are used to store all the data in a database.
    7·1 answer
  • How many pounds must a sand bag weigh to test if a safety net can absorb the proper amount of force? A. 150 lbs. B. 200 lbs. C.
    6·1 answer
  • What effect does social media have on teens?
    10·2 answers
  • 3. Windows that are viewed as Web pages have<br> sections. **
    9·2 answers
  • Ultraportable computers will often use ___ technology exclusively, even though their storage capacity is lower than that of a tr
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!