guys need help please im super lost anyone save me
do programming exercise top_div_array.cpp: Winning Division app (top_div.cpp) revisited to use arrays This is the same program done last week but using and passing arrays instead of individual variables.
// Name: top_div_array.cpp // Description: // This app inputs sales for four regional division and displays the highest. // To accomplish this, use two arrays of equal length - one for sales and the // other for the divisions names. // The data in these arrays will be positioned so that the divisions will share the same // indexes in both arrays. // Use three functions: one for input, one for determining highest sales, and one for // displaying results. #include #include #include using namespace std; // Function Prototypes // These prototypes already contain the proper parameters - // match your work accordingly void populate_div_sales(float[], string[], int); int findHighest (float[], int); // this function will now return the index for // the highest division sales void print_result(float[], string[], int); // displays result based on the index of // highest division sales //************************************************* //************ main ******************************* //************************************************* main () { int top_div_index = 0; // will be assigned the index of the top division sales float div_sales[4]; // array holding the divisions' sales amounts string div_regions[4]; // array holding division names // populate div_regions array div_regions[0] = "Northeast"; div_regions[1] = "Southeast"; // etc. populate_div_sales(div_sales, div_regions, 4); // params are already given to // help get started // leave debug statement in final product cout << "debug print for array div_sales_array" << endl; for (int i=0; i<4; i++) { cout << div_sales[i] << endl; } top_div_index = findHighest(..parameters here..); //will no longer prints the result // leave debug statement in final product cout << "debug for top_div_index: " << top_div_index << endl; print_result(..parameters here..); return 0; } //************ subroutine definitions below ******************* //************************************************* //************ populate_div_sales ***************** //************************************************* // The params for the function definition are given to help get started // - note the f_ preceding variable names. Use // this convention to help relate and contrast both the calling and the // receiving variables. void populate_div_sales(float f_div_sales[], string f_div_regions[], int f_size ) { // loop to input quarterly sales } //************************************************* //************ findHighest ************************ //************************************************* int findHighest (..add parameters..) { float greatestSalesAmount = 0; int save_index; // Use a 'for' loop to help determine the array element with highest sales and // saves the winner's index to save_index return save_index; } //************************************************* //************ print_result *********************** //************************************************* void print_result(..add parameters..) { // Be sure to include the division name and quarterly Sales in the final display }
**********
Comments for the necessary work are included in the start file, but here they are in brief:
HERE IS MY LAST CODE THAT NEEDS TO EDIT FOR THE ARRAY
/*Program: top_div.cpp*/
/*Author: Kim Luis Bundang*/
/*Online class: cs102*/
/*Semester: Spring 2019*/
/*Description: This program should calculate which division in a
company had the greatest sales
for a quarter.*/
//******************
//***Extra Credit***
//******************
//Implemented duplicate top divisions
#include
#include //for strings
#include //for setw
using namespace std;
//declare the function prototypes here (before 'main', as explained in the book)
float input_div(string name);
void findHighest(float nE,float sE,float nW,float sW);
int main()
{
float nE, sE, nW, sW;
nE = input_div( "North East" );
sE = input_div( "South East" );
nW = input_div( "North West" );
sW = input_div( "South West" );
//Prints out entered values for each division. It just looked
better including this
cout << endl << "The sales for North East
division is $" << setprecision(2) << nE;
cout << endl << "The sales for South East
division is $" << setprecision(2) << sE;
cout << endl << "The sales for North West
division is $" << setprecision(2) << nW;
cout << endl << "The sales for South West
division is $" << setprecision(2) << sW;
cout << endl;
findHighest(nE, sE, nW, sW); //prints the result
also
return 0;
}
//************ subroutine definitions below *******************
float input_div(string name) //Code inputs dollar
value for given division and returns it
{
float x;
//Variable
sales will be returned with
cout << fixed << setprecision(2) <<
"Enter the sales for " << name << " division: $";
cin >> x;
//Input Validation
//(Use a while or do/while loop for validation)
while ( x < 0 )
{
cout <<
endl << "Dollar amounts less than $0.00 are not accepted."
<< endl;
cout <<
"Please enter sales for ";
cout <<
name << " division: $" << endl;
cin >> x;
//input sales again
}
return x;
}
void findHighest (float nE,float sE,float nW,float sW )
// Code determines the biggest of 4 floats and prints
the result to the screen.
{
/*
Pseudocode for findHighest(). Use extra variables
to keep track of the highest value and its corresponding name.
Assign these
variables the first values of the data and continue checking for
and updating
the highest data, like this:
*/
float highest;
string name;
highest = nE;
// name = "North East"; //These names have
been commented out for the duplicate code
//This now just determines what the highest sale
value is
if (sE > highest)
{
highest = sE;
// name = "South East";
}
if (nW > highest)
{
highest = nW;
// name = "North West";
}
if (sW > highest)
{
highest = sW;
// name = "South West";
}
//Extra Credit: Code for Duplicates. This will display highest
divisions
if (nE == highest)
{
name = name + "North East ";
}
if (sE == highest)
{
name = name + "South East ";
}
if (nW == highest)
{
name = name + "North West ";
}
if (sW == highest)
{
name = name + "South West ";
}
//Code to display highest
cout << endl << "The " << name
<< "division of the company had the highest sales of $"
;
cout << fixed << setprecision(2) <<
highest << endl;
}
Screenshot
----------------------------------------------------------
Program
// Name: top_div_array.cpp
// Description:
// This app inputs sales for four regional division and displays
the highest.
// To accomplish this, use two arrays of equal length - one for
sales and the
// other for the divisions names.
// The data in these arrays will be positioned so that the
divisions will share the same
// indexes in both arrays.
// Use three functions: one for input, one for determining highest
sales, and one for
// displaying results.
#include<iostream>
#include <string>
#include <iomanip>
using namespace std;
// Function Prototypes
// These prototypes already contain the proper parameters -
//
match your work accordingly
void populate_div_sales(float[], string[], int);
int findHighest(float[], int); // this function will now return the
index for the highest division sales
void print_result(float[], string[],
int); // displays result based on the
index of
// highest
division sales
//*************************************************
//************ main *******************************
//*************************************************
int main()
{
int top_div_index = 0; // will be assigned the index
of the top division sales
float
div_sales[4];
// array holding the divisions' sales amounts
string div_regions[4]; // array holding division
names
// populate div_regions array
div_regions[0] = "Northeast";
div_regions[1] = "Southeast";
div_regions[2] = "Northwest";
div_regions[3] = "Southwest";
populate_div_sales(div_sales, div_regions, 4); //
params are already given to
// help get started
// leave debug statement in final product
cout << "debug print for array div_sales_array"
<< endl;
for (int i = 0; i < 4; i++) {
cout << div_sales[i] <<
endl;
}
top_div_index = findHighest(div_sales,4); //will no longer prints the result
// leave debug statement in final product
cout << "debug for top_div_index: " <<
top_div_index << endl;
print_result(div_sales,div_regions,top_div_index);
return 0;
}
//************ subroutine definitions below *******************
//*************************************************
//************ populate_div_sales *****************
//*************************************************
// The params for the function definition are given to help get
started
//
- note the f_ preceding variable names. Use
//
this convention to help relate and contrast both the calling and
the
//
receiving variables.
void populate_div_sales(float f_div_sales[], string
f_div_regions[], int f_size)
{
float x;
for (int i = 0; i < f_size; i++) {
cout << fixed <<
setprecision(2) << "Enter the sales for "
<<f_div_regions[i]<< " division: $";
cin >> x;
//Input
Validation
//(Use a while or do/while loop for
validation)
while (x < 0)
{
cout <<
endl << "Dollar amounts less than $0.00 are not accepted."
<< endl;
cout <<
"Please enter sales for ";
cout <<
f_div_regions[i] << " division: $" << endl;
cin >> x;
//input sales again
}
f_div_sales[i] = x;
}
}
//*************************************************
//************ findHighest ************************
//*************************************************
int findHighest(float f_div_sales[], int f_size)
{
float greatestSalesAmount = 0;
int save_index;
// Use a 'for' loop to help determine the array
element with highest sales and
// saves the winner's index to save_index
for (int i = 0; i < f_size; i++) {
if (greatestSalesAmount <
f_div_sales[i]) {
greatestSalesAmount = f_div_sales[i];
save_index =
i;
}
}
return save_index;
}
//*************************************************
//************ print_result ***********************
//*************************************************
void print_result(float f_div_sales[], string f_div_regions[],int
index)
{
// Be sure to include the division name and quarterly
Sales in the final display
cout << endl << "The " <<
f_div_regions[index] << " division of the company had the
highest sales of $";
cout << fixed << setprecision(2) <<
f_div_sales[index] << endl;
}
---------------------------------------------------------
Output
Enter the sales for Northeast division: $15
Enter the sales for Southeast division: $10
Enter the sales for Northwest division: $40
Enter the sales for Southwest division: $32
debug print for array div_sales_array
15.00
10.00
40.00
32.00
debug for top_div_index: 2
The Northwest division of the company had the highest sales of $40.00
-------------------------------------------------------------------------------------------
guys need help please im super lost anyone save me do programming exercise top_div_array.cpp: Winning Division...
[C++] Please help to understand why this code need to have "void calcSales(CorpData &);" and "void displayDivInfo(CorpData);". Thanks! ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ #include <iostream> #include <string> using namespace std; struct CorpData { string diviName; double firstQua, secondQua, thirdQua, fourthQua, annualSales, quaAvg; CorpData(string d, double fq, double sq, double tq, double frq) { diviName = d; firstQua = fq; secondQua = sq; thirdQua = tq; fourthQua = frq; } }; void calcSales(CorpData &); void displayDivInfo(CorpData); int main() { CorpData West("West", 10000, 20000,...
Help. Write a C++ program that determines which of a company's four divisions (North, South, East, West) has the greatest sales for the quarter. It should include three functions at a minimum: float getSales() is passed the name of a division. It asks the user for a division's quarterly sales figure, calls a validate() function that will validate the input, and then returns the value back to main(). This function should be called once for each division. void validate() is...
Can anyone help me with my C++ assignment on structs, arrays and bubblesort? I can't seem to get my code to work. The output should have the AVEPPG from highest to lowest (sorted by bubbesort). The output of my code is messed up. Please help me, thanks. Here's the input.txt: Mary 15 10.5 Joseph 32 6.2 Jack 72 8.1 Vince 83 4.2 Elizabeth 41 7.5 The output should be: NAME UNIFORM# AVEPPG Mary 15 10.50 Jack 72 8.10 Elizabeth 41 7.50 Joseph 32 6.20 Vince 83 4.20 My Code: #include <iostream>...
hello there. can you please help me to complete this code. thank you. Lab #3 - Classes/Constructors Part I - Fill in the missing parts of this code #include<iostream> #include<string> #include<fstream> using namespace std; class classGrades { public: void printlist() const; void inputGrades(ifstream &); double returnAvg() const; void setName(string); void setNumStudents(int); classGrades(); classGrades(int); private: int gradeList[30]; int numStudents; string name; }; int main() { ...
I want to change this code and need help. I want the code to not use parallel arrays, but instead use one array of struct containing the data elements, String for first name, String for last name,Array of integers for five (5) test scores, Character for grade. If you have any idea help would be great. #include #include #include #include using namespace std; const int NUMBER_OF_ROWS = 10; //number of students const int NUMBER_OF_COLUMNS = 5; //number of scores void...
//Need help ASAP in c++ please. Appreciate it! Thank you!! //This is the current code I have. #include <iostream> #include <sstream> #include <iomanip> using namespace std; class googlePlayApp { private: string name; double rating; int numInstalls; int numReviews; double price; public: googlePlayApp(string, double, int, int, double); ~ googlePlayApp(); googlePlayApp(); string getName(); double getRating(); int getNumInstalls(); int getNumReviews(); string getPrice(); void setName(string); void setRating(double); void setNumInstalls(int); void setNumReviews(int); void setPrice(double); }; googlePlayApp::googlePlayApp(string n, double r, int ni, int nr, double pr)...
Directions: Create a structure that contains the following data: DivisionName First-QuarterSales Second Quarter Sales Third Quarter Sales Fourth Quarter Sales Total Sales Average Sales Create an enumerated data type of {North,South,East,West} Create an array of this structure with one instance for each enumerated data type listed above. Write a C++ program that will create a menu driven program with the following options: Menu Options: A) Add Data B) Compute Total Sales and Avg Sales C) Display Data D) Division Highest...
can someone please comment through this code to explain me specifically how the variables and arrays are working? I am just learning arrays code is below assignment C++ Programming from Problem Analysis to Program Design by D. S. Malik, 8th ed. Programming Exercise 12 on page 607 Lab9_data.txt Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certain number of miles and write them into a notebook. At the...
Posted this a few hours ago. Can anyone help with this? IN C++ Perform the following: Read 10 bowlers with 3 scores each into 1 string array and 1 numeric array(2 dimension double array) Sort the data by individual bowlers averages, Don't forget to sort their names also. Calculate the average across and store in your existing array. Calculate the average down and store in your existing array. Print out the contents of both arrays. This will print the averages...
I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...