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
vladimir2022 [97]
2 years ago
14

Write a user-defined function that calculates the GPA. For the function name and arguments, use the following: The input argumen

t g is a vector whose elements are the numerical values of the grades. The input argument h is a vector with the corresponding credit hours. The output argument GPA is the calculated GPA. Use the function to calculate the GPA for a student with the following record
Computers and Technology
1 answer:
QveST [7]2 years ago
7 0

Answer:

#include <iostream>

#include <vector>

using namespace std;

void calGPA();

vector<int> g;

vector<int> h;

int main(){

   char pushMore = 'y';

   int fg, fh;

   for (;;){

       if (pushMore == 'n'){

           break;

       } else{

           cout<< "Enter integer for grade: ";

           cin>> fg;

           cout<< "Enter integer for credit hours: ";

           cin>> fh;

           g.push_back(fg);

           h.push_back(fh);

           cout<< "Do you want to add more grade and credit hours? y/n: ";

           cin>> pushMore;

       }

   }

   calGPA();

}

void calGPA(){

   double total = 0, GPA;

   for (int i = 0; i < g.size(); ++i) {

        total +=  g.at(i) * h.at(i) ;

   }

   cout<< "The GPA is : "<< total/g.size();

}

Explanation:

The C++ source code above defines two vectors 'g' and 'h'. The latter holds the grades of a student while the former holds the credit hours for the subject taken. The void 'calGPA' function calculates and prints the student's GPA.

You might be interested in
Convert the following binary to decimal number . <br>a). 101101 ​
KonstantinChe [14]
First things first you have to do write it down which you did
step 2: then you multiply each digit of the binary number by the corresponding power of 2: 1x25 + 0x24 + 1x23 + 1x22 + 0x21 + 1x2 0
step 3: solve the powers: 1x32 + 0x16 + 1x8 + 1x4 + 0x2 + 1x1 = 32 + 0 + 8 + 4 + 0 + 1
step 4: add the numbers written above

32 + 0 + 8 + 4 + 0 + 1 = 45.
So, 45 is the decimal equivalent of the binary number 101101.
5 0
2 years ago
Read 2 more answers
Why does my internet keep disconnecting and reconnecting.
3241004551 [841]

Answer:

Hmm maybe because its failing?

Explanation:

i actually dont know but it happens to me sometimes

6 0
2 years ago
If i were to give you free points woulld you take them?
kipiarov [429]

Answer:

D) friend me

Explanation:

6 0
3 years ago
Read 2 more answers
Graded Assignments may be found at the end of each chapter of the required textbook under the title "Real-World Exercises". Each
mina [271]
Ok chapter 2 be done by 11:59
5 0
3 years ago
Controller Area Network CAN B bus diagnostics is being discussed. Technician A says some modules do not set specific codes that
miss Akunina [59]

Answer:

Both Technician A and Technician B is correct.  

Explanation:

CAN (Controller Area Network) is specially designed for the European cars and the automotive industry, but it has become the popular bus in the industrial automation and also in other applications.  

CAN is the serial communication bus that is designed for flexible and robust performance in a harsh environment.

3 0
3 years ago
Other questions:
  • Privileged instructions 1) generate an interrupt so they can execute before non-privileged instructions. 2) are valid only when
    5·1 answer
  • Why is driving a privilege?
    15·2 answers
  • What computer system was the first to run the unix operating system?
    11·1 answer
  • PLEASE HELP!
    13·2 answers
  • Suppose you are given a bag containing n unbiased coins. You are told that n − 1 of these coins are normal, with heads on one si
    7·1 answer
  • How did you generate a random number for the user to guess?
    9·1 answer
  • Choose the correct answer
    6·1 answer
  • What number will be output by the console.log command on line 5?
    9·1 answer
  • Draw truth table for the following logic circuit:<br><br> (Please I really need help with this)
    15·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!