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.

Recommended Answers

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.

Jump to Post

All 3 Replies

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.

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..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.