# computer science

posted by .

my code works in c++ so the logical I am getting error must be in the reading of the problem, but I can't see it:

Given a type Money that is a structured type with two int fields, dollars and cents. Assume that an array named monthlySales with 12 elements, each of type Money has been declared and initialized.

Assume that a Money variable yearlySales has also been declared. Write the necessary code that traverses the monthlySales array and adds it all up and stores the resulting total in yearlySales. Be sure make sure that yearlySales ends up with a valid value, i.e. a value of cents that is less than 100.

Money monthlySales[12];
yearlySales.cents = 0;
yearlySales.dollars = 0;

for(int j = 0; j < 12; j++)
{
cin >> monthlySales[j].dollars;
cin >> monthlySales[j].cents;
}

for(int i = 0; i < 12; i++)
{
yearlySales.cents = yearlySales.cents + monthlySales[i].cents;

yearlySales.dollars = yearlySales.dollars + monthlySales[i].dollars;

}
while(yearlySales.cents > 100)
{
yearlySales.cents -= 100;
yearlySales.dollars += 1;
}

• computer science -

Here's a little detail:
while(yearlySales.cents 100)
{...

Can you post your Money class, data and output?

• computer science -

You also missed out
int main(){
}

Otherwise it should work as expected.

• computer science -

myprogramming lab- the bane of my existance- code works in c++ but not in myprogramminglab so I wondered if I was missing something in the question

• computer science -

But double-checking with a real programming language is the way to go.

## Similar Questions

1. ### computer science

Algorithm for Binomial Numbers Task Binomial numbers (or binomial coefficients) are important positive integers that arise frequently in computing and mathematics. A function to compute binomial coefficients will have two inputs: n …
2. ### mathematics

seeds of type A and type B are sold in packets, each must contain 1) both type a and type b seeds 2) at least twice the amount of type B as there are type A 3) no more than 12 seeds state the minimum number in each paket of type A …
3. ### math-Statistics

I have been working on the Type I error and a Type II error problem but now I can not figure out the Power of the test?
4. ### computer programming

Construct a structure chart, as well as a flowchart and pseudocode, for the following problem. Assume that each input record contains a taxpayerâ€™s name, the value of a personal property belonging to the taxpayer, and a code …
5. ### computer science

What is a type of operator that uses the AND, OR, and NOT?
6. ### statistics

The power of a significance test for a particular value of the parameter is computed to be 0.93. Which statement below is true?
7. ### computer science

Assume that BlogComment is a structured type with these fields, comment (a string, the actual comment), and two int fields: like, dislike which count the number of "likes" and "dislikes" of the comment by visitors. Assume that nComments …
8. ### Statistics

A test is made of H0: mean = 27 versus H1: mean < 27. The true value of the mean is 27, and H0 is rejected. Is this a Type I error, Type II error, or a correct decision?
9. ### math

In printing an article of 21,000 words, a printer decides to use two sizes of type. Using the larger type, a printed page contains 1,200 works. Using the smaller type type, a page contains 1,500 words. The article is allotted 16 full …
10. ### itcs 1140

Homework # 4 ~ Strategic Planning for Wy’East Coffee solve it on pyhon A good friend of yours, Madeline, owns a small, rather successful coffee shop near center campus. She has gathered some data in an Excel spreadsheet over the …

More Similar Questions