14 Aug computer science
Q1. – Find The Bugs (5 bugs)
// College maintains a master file of students and credits earned.
// Each semester the master is updated with a transaction file
// that contains Student ID and credits earned during the semester.
// Each file is sorted in Student ID number order. Student name only exists in the master file.
start
Declarations
num masterID
string masterName
num masterCredits
num transID
string bothDone = "N"
num HIGH_VALUE = 999999
InputFile master
InputFile trans
OutputFile newMaster
getReady()
while bothDone = "N"
detailLoop()
endwhile
allDone()
stop
getReady()
open master "studentFile.dat"
open transaction "semesterCredits.dat"
open newMaster "updatedStudentFile.dat"
readMaster()
readTrans()
checkBoth()
return
readMaster()
input masterID, masterName, credits from master
if eof then
masterID = HIGH_VALUE
endif
return
readTrans()
input transID, transCredits from trans
if eof then
transID = HIGH
endif
return
checkBoth()
if masterID = HIGH_VALUE OR transID = HIGH_VALUE then
bothDone = "Y"
endif
return
detailLoop()
if masterID = transID then
match()
else
if masterID > transID then
noMasterForTrans()
else
noTransForMaster()
endif
endif
checkBoth()
return
match()
masterCredits = masterCredits + transCredits
output masterID, masterName, masterCredits to newMaster
readMaster()
readTrans()
return
noMasterForTrans()
output "No master file record matches transaction ", transID
readTrans()
return
noTransForMaster()
output masterID, masterName, masterCredits to newMaster
readMaster()
return
allDone()
close master
close trans
close newMaster
return
Q2. - The Library keeps a file of all books borrowed every month. Each file is in Library of Congress number order and contains additional fields for author and title. Write the pseudocode for a program that merges the files for January and February to create a new file with all of the books borrowed in the two-month period. Be sure to use appropriate modules!
Q3. – Do the following Exercise. Be sure to use appropriate modules!
Norman's Department Store keeps a record of every sale including a transaction number (T1, T2,…), the dollar amount of the sale, and the department number in which the sale was made (department number values are 1 through 3 for this example). Design the logic for a program that inputs the sales data (transaction number, dollar amount of sale, and department number) which are sorted by department number, and outputs a report to a file showing the department number, transaction number and amount for each sale, with a total dollar amount at the change/end of each department and a Grand Total at the end of the report (see sample below).
Sample data for "NormanSales.txt" inputfile:
T1, 250, 1
T2, 500, 1
T3, 100, 2
T4, 300, 2
T5, 200, 2
T6, 350, 3
T7, 250, 3
T8, 150, 3
Sample of the OUTPUT (report file – "NormanReport.txt") – do not worry about the spacing between data:
Sales by Department
Department Transaction Sales Value
1 T1 250
1 T2 500
Department Total is 750
2 T3 100
2 T4 300
2 T5 200
Department Total is 600
3 T6 350
3 T7 250
3 T8 150
Department Total is 750
Grand Total is 2100
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Wridemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.