50 D ATT LTE 1052 AM Expert QA Done C programming The ABC CO

50% D AT&T; LTE 10:52 AM Expert Q&A; Done C++ programming The ABC CORPORATION wishes to review sgroup products based on their of ior each quarter in fiscal company products mpany has the year, Having heard programming experience the hired you to write a complete C program, inchudrg oomm to do the 1. Read in which wil indicate how many bems should be analyzed. This wil be followed by n groups of data each containing information about 1 product group of information name ofte em and then 4 indicating the profit loss) made on that hem during the 4 quarterly reporting periods For example one group of data could be Diskettes 32 63 -12 84 or Printers .23 564 45 75 2. Print the data as it read in in the form of a table with one row for each iem and one column for each reporting period the totalprofit for each term throughout the year. Also determine the total profit for the company and the average profit for each item ootal profit Print ese values with appropriate messages. 4. For each of the 4 quarters determine which iem had the greatest profit for that quarter. Print out the quarter number, item with the most profit and the amount of profit for that item. For each quarter determine how many nems profit in that quarter and how many items had a loss in quarter and print those results as well. For each quarter the sum of these two numbers should equal the number of items processed. 6. For each item determine irthe profit for that term steadily increased leach quaner had profit higher then the previous decreased or it went up and down during the course of the year. Print these results as wel For this assignment you may use interactive data entry or an external fue (easier). Make up your own data and use approximately 10 to 15 items some always profitable some partially and some that lost money. Please cover all possibilities. Each part ofthe program should be written using one or more functions. You should decide what parameters to send to these functions.

Solution

#include<iostream>
#include<stdio.h>
using namespace std;
int no, p[100][4], ip[100];
float avi[100];
char name[100][10];
//Accepts item information
void acc()
{
int c, d;
cout<<\"\ Enter number of items: \";
cin>>no;
for(c = 0; c < no; c++)
{
cout<<\"\ Enter Item \"<<c+1<<\" Name: \";
cin>>name[c];
fflush(stdin);
//Accepts quarter data
for(d = 0; d < 4; d++)
{
cout<<\"\ Enter Item \"<<c+1<<\" Profit / Loss Data: \";
cin>>p[c][d];
}
}
}
//Displays the item information
void disp()
{
int c, d;
for(c = 0; c < no; c++)
{
cout<<name[c]<<\": \";
//Displays each quarter information
for(d = 0; d < 4; d++)
cout<<p[c][d]<<\" \";
cout<<endl;
}
}
//Displays total profit of each item and average profit of each item with company profit
void statement()
{
int c, d, tp = 0;
for(c = 0; c < no; c++)
{
ip[c] = 0; avi[c] = 0;
for(d = 0; d < 4; d++)
{
tp = tp + p[c][d];
ip[c] = ip[c] + p[c][d];
}
//calculates average profit
avi[c] = (float)ip[c] / 4;
}
//Displays information
for(c = 0; c < no; c++)
{
cout<<\"\ Total profit of Item: \"<<name[c]<<\" = \"<<ip[c];
cout<<\"\ Average profit of Item: \"<<name[c]<<\" = \"<<avi[c];
}
cout<<\"\ Total profit of the company: \"<<tp;
}
//Most profit in each quarter
void mostProfit()
{
int c, d, qa, pr, big = 0;
for(c = 0; c < 4; c++)
{
for(d = 0; d < no; d++)
{
//find out the biggest profit
if(big < p[d][c])
{
big = p[d][c];
pr = d;
qa = c;
}
}
big = 0;
cout<<\"\ Quarter Number: \"<<c+1<<\" \ Item Name: \"<<name[pr]<<\"\ Profit: \"<<p[pr][qa];
}
}
//Displays number of profit and loss
void numProfitLoss()
{
int c, d, np, nl;
for(c = 0; c < 4; c++)
{
np = nl = 0;
for(d = 0; d < no; d++)
{
if(p[d][c] > 0)
//count for number of profit
np++;
else
//count for number of loss
nl++;
}
cout<<\"\ Quarter Number: \"<<c+1<<\" Number of Profit: \"<<np<<\" Number of Loss: \"<<nl;
}
}
//Displays Item status
void status()
{
int c, d = 0;
for(c = 0; c < no; c++)
{
if(p[c][d] < p[c][d+1] && p[c][d+1] < p[c][d+2] && p[c][d+2] < p[c][d+3] )
cout<<\"\ Item \"<<name[c]<<\" is steadily increasing\";
else if(p[c][d] > p[c][d+1] && p[c][d+1] > p[c][d+2] && p[c][d+2] > p[c][d+3] )
cout<<\"\ Item \"<<name[c]<<\" is steadily decreasing\";
else
cout<<\"\ Item \"<<name[c]<<\" went up and down\";
}
}
int main()
{
acc();
cout<<\"\ Item Information \ \";
disp();
cout<<\"\ Status of the Item \ \";
statement();
cout<<\"\ Most profit item in a quarter \ \";
mostProfit();
cout<<\"\ Number of profit and number of loss \ \";
numProfitLoss();
cout<<\"\ Status of each item \ \";
status();
}

Output:

Enter number of items: 3

Enter Item 1 Name: a

Enter Item 1 Profit / Loss Data: -10

Enter Item 1 Profit / Loss Data: -20

Enter Item 1 Profit / Loss Data: -40

Enter Item 1 Profit / Loss Data: 90

Enter Item 2 Name: b

Enter Item 2 Profit / Loss Data: -10

Enter Item 2 Profit / Loss Data: 30

Enter Item 2 Profit / Loss Data: 60

Enter Item 2 Profit / Loss Data: 70

Enter Item 3 Name: c

Enter Item 3 Profit / Loss Data: 50

Enter Item 3 Profit / Loss Data: 30

Enter Item 3 Profit / Loss Data: -10

Enter Item 3 Profit / Loss Data: -30

Item Information
a: -10 -20 -40 90
b: -10 30 60 70
c: 50 30 -10 -30

Status of the Item

Total profit of Item: a = 20
Average profit of Item: a = 5
Total profit of Item: b = 150
Average profit of Item: b = 37.5
Total profit of Item: c = 40
Average profit of Item: c = 10
Total profit of the company: 210
Most profit item in a quarter

Quarter Number: 1
Item Name: c
Profit: 50
Quarter Number: 2
Item Name: b
Profit: 30
Quarter Number: 3
Item Name: b
Profit: 60
Quarter Number: 4
Item Name: a
Profit: 90
Number of profit and number of loss

Quarter Number: 1 Number of Profit: 1 Number of Loss: 2
Quarter Number: 2 Number of Profit: 2 Number of Loss: 1
Quarter Number: 3 Number of Profit: 1 Number of Loss: 2
Quarter Number: 4 Number of Profit: 2 Number of Loss: 1
Status of each item

Item a went up and down
Item b is steadily increasing
Item c is steadily decreasing

 50% D AT&T; LTE 10:52 AM Expert Q&A; Done C++ programming The ABC CORPORATION wishes to review sgroup products based on their of ior each quarter in fi
 50% D AT&T; LTE 10:52 AM Expert Q&A; Done C++ programming The ABC CORPORATION wishes to review sgroup products based on their of ior each quarter in fi
 50% D AT&T; LTE 10:52 AM Expert Q&A; Done C++ programming The ABC CORPORATION wishes to review sgroup products based on their of ior each quarter in fi
 50% D AT&T; LTE 10:52 AM Expert Q&A; Done C++ programming The ABC CORPORATION wishes to review sgroup products based on their of ior each quarter in fi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site