Question

In: Computer Science

a file named maintence08-01.txt is included with your downloadable student files. Assume that this program is...

a file named maintence08-01.txt is included with your downloadable student files. Assume that this program is a working program in your organization and that it needs modifications that are described in the comments(lines that begin with two slashes) at the beginning of the file. Your job is to alter the program to meet the new specifications.


Here is the file Maintence08-01.txt

// 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

Solutions

Expert Solution

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

getReady()
count = 0
output "Enter required size"
input reqSize
SIZE = Min(reqSize,MAx_SIZE)
while count < SIZE
output "Enter salesperson name "
names.add(input)
output "Enter number of properties sold "
properties.add(input)
output "Enter total value of those properties "
values.add(input)
count = count + 1
endwhile
return

display()
output "Show top salesperson by value(Type1) or properties sold (Type 2)"
input(choose)
if choose == 1
sortvalues()
endif
if choose == 2 
sortproperties()
endif
count = 0
NUM_TO_DISPLAY = min(MAX_NUM_TO_DISPLAY,SIZE)
while count < NUM_TO_DISPLAY
output names[count], properties[count], values[count]
count = count + 1
endwhile
return


finish()
output "End of display"
return

sortvalues()
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

sortproperties()
comps = SIZE - 1
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

I've implied that we are using dynamic size array, rest of the program is self explanatory. Do let me know if you need any help nonetheless.


Related Solutions

Each of the following files in the Chapter15 folder of your downloadable student files has syntax and/or logic errors.
Each of the following files in the Chapter15 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded with Fix. For example, DebugFifteen1.java will become FixDebugFifteen1.java. a. DebugFifteen1.java b. DebugFifteen2.java c. DebugFifteen3.java d. DebugFifteen4.java    
[In Python] Write a program that takes a .txt file as input. This .txt file contains...
[In Python] Write a program that takes a .txt file as input. This .txt file contains 10,000 points (i.e 10,000 lines) with three co-ordinates (x,y,z) each. From this input, use relevant libraries and compute the convex hull. Now, using all the points of the newly constructed convex hull, find the 50 points that are furthest away from each other, hence giving us an evenly distributed set of points.
Write a python program: There is a file called file 2. File2 is a txt file...
Write a python program: There is a file called file 2. File2 is a txt file and I have written the contents of file 2 below in the exact format it was in notepad. # This comment does not make sense # It is just to make it harder # The job description starts after this comment, notice that it has 4 lines. # This job description has 700150 hay system points\\ the incumbent will administer the spending of kindergarden...
JAVA - Quick Sort .txt and Return ----------------------------------------------------------------------------- The program should input a .txt file like...
JAVA - Quick Sort .txt and Return ----------------------------------------------------------------------------- The program should input a .txt file like below and must use a Quick sort Algorithm ================ 6 10 4 19 10 12 8 6 0 1 2 3 ================ The first number "6" represents the index of the element to return after sort the second number on the top "10" represents the number of elements or size of array. The following numbers and lines are the elements that need to go...
Write a php program that writes numbers to a file. The file type should be .txt...
Write a php program that writes numbers to a file. The file type should be .txt and the file name should be numbers.tx. The numbers.txt should contain 10 random integers between 1 to 100 after the file is written.
Create a c++ program with this requirements: Create an input file using notepad ( .txt )...
Create a c++ program with this requirements: Create an input file using notepad ( .txt ) . When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File”...
Python Code Assignment 1. Place the two provided plaintext files (file_1.txt, file_2.txt) on your desktop. 2....
Python Code Assignment 1. Place the two provided plaintext files (file_1.txt, file_2.txt) on your desktop. 2. Write a Python program named fun_with_files.py. Save this file to your desktop as well. 3. Have your program write the Current Working Directory to the screen. 4. Have your program open file_1.txt and file_2.txt, read their contents and write their contents into a third file that you will name final.txt . Note: Ponder the open‐read/write‐close file operation sequence carefully. 5. Ensure your final.txt contains...
Create a cronjob which does the following tasks 1.) create a file named <yourname>.txt 2.) in...
Create a cronjob which does the following tasks 1.) create a file named <yourname>.txt 2.) in the 35th minute of the hour change the permission to 755 3.) Create a shell script named first.sh in which you print your name and redirect the output by 45th minute of the hour to the text file
Exercise 2: You are provided with a text file named covid19-3.txt. It reports a few confirmed...
Exercise 2: You are provided with a text file named covid19-3.txt. It reports a few confirmed cases of covid19. It consists of three columns. The 1st column indicates the names of the provinces, the 2nd column indicates the names of the countries and the 3rd column indicates the numbers of confirmed cases. To do: 1. Define a function that reads, from covid19-3.txt, provinces, countries and confirmed cases in three separate lists. 2. Define a function that iterates through a list...
Create a c++ program that: Create an input file using notepad ( .txt ). When testing...
Create a c++ program that: Create an input file using notepad ( .txt ). When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File” marker. Input date...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT