Question

// This application reads sales data for a real estate broker. // The user enters a...

// This application reads sales data for a real estate broker.
// The user enters a record for each of 10 salespeople
//    containing the salesperson's name,
//    the number of properties sold by that person during the month,
//    and the total value of those properties.
// The data records are sorted by value so the data for
//    the top three salespeople can be displayed.
// Modify the program to
// (1) enter data for any number of salespeople up to 60
// (2) allow the user to choose whether to see
//       (a) the data for the top three salespeople
//           (or fewer if 3 are not entered) by value
//       (b) the data for the top three salespeople
//           (or fewer if 3 are not entered) by
//           number of properties sold

start
   Declarations
      num SIZE = 10
      string names[SIZE]
      num properties[SIZE]
      num values[SIZE]
      num count
      num NUM_TO_DISPLAY = 3
      num comps
      num x
      num y
      num tempProp
      num tempVal
      string tempName
   getReady()
   display()
   finish()
stop

getReady()
   count = 0
   while count < SIZE
      output "Enter salesperson name "
      input names[count]
      output "Enter number of properties sold "
      input properties[count]
      output "Enter total value of those properties "
      input values[count]
      count = count + 1
   endwhile
return

display()
   sort()
   count = 0
   while count < NUM_TO_DISPLAY
      output names[count], properties[count], values[count]
      count = count + 1
   endwhile
return


finish()
   output "End of display"
return

sort()
   comps = SIZE - 1
   while y < comps
      x = 0
      while x < comps
         if values[x] < values[x + 1] then
            swap()
         endif
         x = x + 1
      endwhile
      y = y + 1
   endwhile
return

void swap()
   tempName = names[x + 1]
   names[x + 1] = names[x]
   names[x] = tempName
   tempProp = properties[x + 1]
   properties[x + 1] = properties[x]
   properties[x] = tempProp
   tempVal = values[x + 1]
   values[x + 1] = values[x]
   values[x] = tempVal
return

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// This application reads sales data for a real estate broker.

// The user enters a record for each of 10 salespeople

//    containing the salesperson's name,

//    the number of properties sold by that person during the month,

//    and the total value of those properties.

// The data records are sorted by value so the data for

//    the top three salespeople can be displayed.

// Modify the program to

// (1) enter data for any number of salespeople up to 60

// (2) allow the user to choose whether to see

//       (a) the data for the top three salespeople

//           (or fewer if 3 are not entered) by value

//       (b) the data for the top three salespeople

//           (or fewer if 3 are not entered) by

//           number of properties sold

start

   Declarations

      num SIZE = 60

      string names[SIZE]

      num properties[SIZE]

      num values[SIZE]

      num count

      num NUM_TO_DISPLAY = 3

      num comps

      num x

      num y

      num tempProp

      num tempVal

               num num_data // input for number of salespeople

               num choice // input for choice to sort

      string tempName

               getReady()

               // user input for sort

               output "Enter 1 to display salespeople by value or 2 to display salespeople by properties sold"

               input choice

               if choice == 1

                              sortByValue()

               else

                              sortByProperties()                                         

   display()

   finish()

stop

getReady()

               // input of actual number of salespeople

               output "Enter number of salespeople(max 60) : "

               input num_data

               if num_data < NUM_TO_DISPLAY

                              NUM_TO_DISPLAY = num_data

               endif

               count = 0

               while count < num_data

      output "Enter salesperson name "

      input names[count]

      output "Enter number of properties sold "

      input properties[count]

      output "Enter total value of those properties "

      input values[count]

      count = count + 1

   endwhile

return

display()

               count = 0

               while count < NUM_TO_DISPLAY

      output names[count], properties[count], values[count]

      count = count + 1

               endwhile

return

finish()

   output "End of display"

return

sortByValue()

               comps = num_data - 1

               y=0

               while y < comps

                              x = 0

                              while x < comps

                                             if values[x] < values[x + 1] then

                                                            swap()

                                             endif

                                             x = x + 1

                              endwhile

                              y = y + 1

   endwhile

return

sortByProperties()

               comps = num_data-1

               y=0

               while y < comps

                              x=0

                              while x < comps

                                             if properties[x] < properties[x + 1] then   

                                                            swap()

                                             endif

                                             x = x + 1

                              endwhile

                              y = y + 1

               endwhile

return   

void swap()

   tempName = names[x + 1]

   names[x + 1] = names[x]

   names[x] = tempName

   tempProp = properties[x + 1]

   properties[x + 1] = properties[x]

   properties[x] = tempProp

   tempVal = values[x + 1]

   values[x + 1] = values[x]

   values[x] = tempVal

return

Add a comment
Know the answer?
Add Answer to:
// This application reads sales data for a real estate broker. // The user enters a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Find Bugs in the pseudocode // A high school is holding a recycling competition // This program allows a user to enter a student's // year in school (1 through 4) // and number of cans collected // Data is entered continuously until the user wnats

    Find Bugs in the pseudocode// A high school is holding a recycling competition// This program allows a user to enter a student's // year in school (1 through 4)// and number of cans collected// Data is entered continuously until the user wnats to quit// After headings, output is four lines// one for each school year classstart   Declarations      num year      num cans      num SIZE = 4      num QUIT = 9    ...

  • Turning this Pseudocode into the described C++ Program? (will include Pseudocode AND Description of the Program...

    Turning this Pseudocode into the described C++ Program? (will include Pseudocode AND Description of the Program below!) Pseudoode: start   Declarations num deptNum num salary num hrsWorked num SIZE = 7 num totalGross[SIZE] = 0 string DEPTS[SIZE] = “Personnel”, “Marketing”,   “Manufacturing”, “Computer Services”, “Sales”, “Accounting”, “Shipping”                                                      getReady()    while not eof detailLoop()    endwhile    finishUp() stop getReady()    output “Enter the department number, hourly salary, and number of hours worked”    input deptNum, salary, hrsWorked return detailLoop()    if deptNum >= 1 AND deptNum...

  • For the following C# program: Let’s add one more user defined method to the program. This...

    For the following C# program: Let’s add one more user defined method to the program. This method, called ReverseDump is to output the values in the array in revere order (please note that you are NOT to use the Array.Reverse method from the Array class). The approach is quite simple: your ReverseDump method will look very similar to the Dump method with the exception that the for loop will count backwards from num 1 to 0 . The method header...

  • Project 4: Month-end Sales Report with array and validation Input dialog box for initial user prompt...

    Project 4: Month-end Sales Report with array and validation Input dialog box for initial user prompt with good data and after invalid data Input OK Cancel Input dialog boxes with sample input for Property 1 Ingut X Input Enter the address for Property 1 Enter the value of Property 1: OK Cancel Input dialog boxes after invalid data entered for Property 1 Error Please enter anmumber greater than D Ester the walue of Peoperty t Console output END SALES REPORT...

  • howthe   output   of   the   following   4   program segments (a)    const int SIZE=8;    int values[SIZE]...

    howthe   output   of   the   following   4   program segments (a)    const int SIZE=8;    int values[SIZE] = {10, 10, 14, 16, 6, 25, 5, 8};    int index;    index=0;    res = values[index];    for (int j=1; j<SIZE; j++)    {        if (values[j] > res)        {            res = values[j];            index = j;        cout << index << res << endl;        }    }    cout <<...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • I need to update this C++ code according to these instructions. The team name should be...

    I need to update this C++ code according to these instructions. The team name should be "Scooterbacks". I appreciate any help! Here is my code: #include <iostream> #include <string> #include <fstream> using namespace std; void menu(); int loadFile(string file,string names[],int jNo[],string pos[],int scores[]); string lowestScorer(string names[],int scores[],int size); string highestScorer(string names[],int scores[],int size); void searchByName(string names[],int jNo[],string pos[],int scores[],int size); int totalPoints(int scores[],int size); void sortByName(string names[],int jNo[],string pos[],int scores[],int size); void displayToScreen(string names[],int jNo[],string pos[],int scores[],int size); void writeToFile(string...

  • The name of the C++ file must be search.cpp Write a program that will read data...

    The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...

  • 1.The following statement gets an element from position 4 in an array named myArray: x =...

    1.The following statement gets an element from position 4 in an array named myArray: x = myArray[4]; What is the equivalent operation using an array list named list.? A x = list.get(); B x = list.get(4); C x = list.get[4]; D x = list[4]; 2.Consider the following code snippet: ArrayList<Integer> num1 = new ArrayList<Integer>(); int data; Scanner in = new Scanner(System.in); for (int i = 0; i < 5; i++) { data = in.nextInt(); num1.add(data); if (data == 0 &&...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT