Cameron B.

asked • 10/02/15

C++ Programming Homework Due Tonight :(

I'm pretty sure this assignment is really easy but I haven't learned anything in the class.

Basically he wants us to rewrite part of a program as a module.

#include <iostream>

using namespace.std;

int main()
{
int count;
double num, total;

cout << “Please enter a number”;
cin >> num;

for (count = 1; count <=num; count = count + 1)d
{
// Re-write this section as a module
cout << “Current number: “ << count << endl;
cout << “Total so far: “ << total << endl;
}NN

cout << “Your total is: “ << total << endl;

return 0;


Please help I'm getting a tutor monday but this is due tonight.

Ric D.

I am actually taking the same class.
I just submitted my assignment.

I am not entirely sure if I followed it correctly as I think the assignment wasn't entirely clear.
If I am not mistaken, what you want to do is create two prototype functions (See page 226)
One for each of these lines

cout << “Current number: “ << count << endl;
cout << “Total so far: “ << total << endl;

so you end up with one function that counts and one function that totals.

Then in those lines, call the function instead of just displaying the output variables.
(See example on 249)

so you'd have something like  cout << “Current number: “ << function() << endl;

This will make your outputs the result of the values your function is returning.

I had to make a lot of small adjustments to the code in general to get it to work properly, and I am not 100% sure this is what the assignment is even asking us to do but that is what I ended up submitting. (Along with a long comment that basically complained about how the assignment was unclear and that we should have been given working code to revise from)

Best of luck
Report

10/02/15

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.