Program in C++

How to solve it?

A trader wants to survey the profits of goods he sells. For this he had to enter each commodity, the commodity code (an integer between 100 and 1000), the purchase price and the selling price. When there are no more goods enter -1. Make the program that reads the data and determine with them and write on the screen:
The profit of each commodity
The average profit of the company
The total of goods that provide income below $ 15.00
The total of goods that provide income between $ 15.00 and $ 20.00
The total of goods that provide income above $ 20.00
Ok... so what do you have so far?
I do not know how should I start. Will I have to create a function? Seems to involve repetition structures...
Hmm I can give you a tiny skeleton to start with to nudge you in the right direction.First of all are there any requirements for this program like do you need a switch statement and what has the last lesson you are looking at. But for starting out I would us something like this:(note im still fairly new to c++ so I may not give the most efficient answer but might as well try to help XD). I am leaving out some of the variables so you can figure out.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <cfloat>
using namespace std;


int code; //can use this for a switch statement, can also be your EoF value.
float salePrice;
float purchPrice;

int main()
{
   cout<<"Whatever introduction statement"

do
  switch(code)
         case "whatever code value ":
                 {Insert whatever you value and quantity. Also formulas.}
         case ....:
         ......
         case -1: // your EoF value 

       cout<< whatever necessary values you need to insert.
while()


I'll be glad to answer any questions as long as you show that you are making an effort to try to learn =P
Last edited on
Topic archived. No new replies allowed.