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]
3 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]3 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
How does math help you determine the amount of watts a turbine produces?
vlada-n [284]
It helps you determine the amount of watts a turbine produces because math is the only way to go
7 0
4 years ago
A user has just clicked the OK button on a Web form. Which technology is often used to process information sent from the form?
Taya2010 [7]
Still cant tell which is which
7 0
3 years ago
Which intel processor technology interconnects the processor, chipset, and wireless network adapter as a unit, improving laptop
Ira Lisetskai [31]
Apu?
....................
8 0
4 years ago
What is logic gate? ​
Firdavs [7]
A logic gate is an idealized or physical device implementing a Boolean function; that is, it performs a logical operation on one or more binary inputs and produces a single binary output.
7 0
3 years ago
Read 2 more answers
What is computer issue
ludmilkaskok [199]
There's MANY things that count as computer issues.
1) when your computer freezes.
2) When your computer runs slow.
3) when your computer takes hours to download, but never does.
4) Glitches (that can lead to crashes).
5) it could be an internal server error.

Need more or this good?
8 0
3 years ago
Other questions:
  • Which registry hive is loaded first during windows startup?
    5·1 answer
  • To “synthesize” means to combine information to create new information.<br> YES or NO
    10·2 answers
  • What are some of the issues that organizations need to be aware of when designing and managing data?
    8·1 answer
  • In a virtual memory system, each process must have its own page table.(True or False?)
    13·1 answer
  • What was the history of technology since the 1980s to now and how is it used in classrooms?.?. PLEASE HELP
    13·1 answer
  • Suggest why people might not want the government to carry out Internet surveillance?​
    8·2 answers
  • Fill in the blanks : To store 3 character a computer occupies...................bytes memory space​
    8·2 answers
  • What are the benefits of building redundancy into a network?
    12·1 answer
  • 50 POINTS How do you express yourself and your creativity through computer science?
    12·1 answer
  • What is the difference between
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!