0

I am trying to figure out how to create a C++ program that has a Subtotal and a Grandtotal. Could someone please help start a program? It has to have a selection and repetition structure in it.

4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by phorce
1

It is really in bad taste (and unethical) to ask people to do your homework for you. Make an honest effort to solve the problem, and we will be happy to help you, but you have to make a start.

-1

Like everyone else has said, you should atleast attempt it before posting on here!

Maybe this might help..

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

double subTotal(vector<double> &values)
{
    return accumulate(values.begin(),values.end(),0);
}

int main(int argc, char *argv[]) {

    vector<double> numbers;

    numbers.push_back(10);
    numbers.push_back(20);
    numbers.push_back(9);
    numbers.push_back(8);

    cout << subTotal(numbers) << endl;
}

It might give you an idea how to do stuff like Grandtotal etc..

Edited by phorce

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.