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
How dependent are we on technology? ​
rusak2 [61]

very independent  : ) we use it for everything

3 0
3 years ago
Read 2 more answers
What does the KISS Principle stand for?
ivanzaharov [21]

Keep it simple stupid


7 0
3 years ago
Read 2 more answers
Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. Uppercase
satela [25.4K]

Answer:

Read the file and save it to a variable as a string, split the string variable and cast it to a set object using the set function to get the unique words in the file. Then use the max function with the key attribute to use regular expression module "re" to compare the first letter of each item to return in a list comprehension or append to a list.

Explanation:

The open function is used to import a file in python, the split string method splits the string to a list of items and the set function removes any duplicates of a word or item.

Using the for loop statement, iterate over the items and compare and return the items in alphabetical order with the 're' search method getting the item with uppercase letters with higher precedence than lowercase.

5 0
3 years ago
What is the difference between master file and transaction file​
klio [65]

Answer:

master file contains data types while transaction file is used to record Master file

Explanation:

hope it helps

3 0
3 years ago
Which of the following tasks requires you to use the Tabs option?
LenaWriter [7]
In Microsoft Word, the TAB button shifts the text to the right. For example, starting a new paragraph, the TAB button indents the beginning.<span />
3 0
3 years ago
Other questions:
  • What does Mishler mean by the foreground-background interaction? How can this affect the photographs, based on the examples in t
    14·2 answers
  • Life can get busy and hectic but relationships matter what is an effective way to mending relationships that may have been negle
    9·1 answer
  • Which is an example of an active visual interface? a display indicating the amount of ammunition for the currently equipped weap
    13·2 answers
  • Taken together, the physical and data link layers are called the ____________________. Internet layer Hardware layer Internetwor
    15·1 answer
  • In JAVA please:
    15·1 answer
  • Which type of memory helps in reading as well as writing data? With the help of , a computer can read as well as write or modify
    11·3 answers
  • When a recipient responds to a meeting request, which statement most accurate descries what occurs?
    5·2 answers
  • What do you mean by hardware and software?<br>​
    12·2 answers
  • What is the importance of shape in graphic design?​
    5·2 answers
  • Identify the two top benefits of using angel investors to start a business.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!