Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program using C ++ (microsoft visual studios 2013) using atleast one fo

ID: 3798853 • Letter: C

Question

Create a program using C ++ (microsoft visual studios 2013) using atleast one for loop that displays the sales amounts made in each of four regions (north, south, east and west) for t 3 month period. The program should allow the user to enter 4 sets (one set for each region) of three sales amounts (one amount for each month). The program should display each regions total sales for the 3 month period. Example data(remember that the user should be able to enter any data they wish as long as it follows the format below):

north 2000, 3400, 4000

south 2232, 3434, 6777

east 2222, 5555, 1035

west 1111, 4000, 4444

Explanation / Answer

#include <iostream>

using namespace std;

int main()
{
int n = 4;
string regions[n];
int salesAmount[n][3];

for(int i=0; i<n; i++){
cout<<"Enter the region and 3 months sales amounts: ";
cin >> regions[i]>>salesAmount[i][0]>>salesAmount[i][1]>>salesAmount[i][2];
}
for(int i=0; i<n; i++){
cout<<"Region: "<<regions[i]<<" Total sale amount: "<<(salesAmount[i][0]+salesAmount[i][1]+salesAmount[i][2])<<endl;
}

return 0;
}

Output:

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                                              

sh-4.2$ main                                                                                                                                                                                                                                                           

Enter the region and 3 months sales amounts: north 2000 3400 4000                                                                                                                                                                                                      

Enter the region and 3 months sales amounts: south 2232 3434 6777                                                                                                                                                                                                      

Enter the region and 3 months sales amounts: east 2222 5555 1035                                                                                                                                                                                                       

Enter the region and 3 months sales amounts: west 1111 4000 4444                                                                                                                                                                                                       

Region: north Total sale amount: 9400                                                                                                                                                                                                                                  

Region: south Total sale amount: 12443                                                                                                                                                                                                                                 

Region: east Total sale amount: 8812                                                                                                                                                                                                                                   

Region: west Total sale amount: 9555

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote