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

In this problem, how do I write the pseudocode in such a way that it matches the

ID: 3828361 • Letter: I

Question

In this problem, how do I write the pseudocode in such a way that it matches the correct customer name with the address, city, etc? Without knowing the structure of the file it's difficult. Is there a way to say "output firstName, lastName, streetAddress, city, state, zipCode FROM ROW WHERE customerID = enteredID"?

https://www.chegg.com/homework-help/Programming-Logic-and-Design-Introductory-8th-edition-chapter-7-problem-1PE-solution-9781285972619

**DO NOT POST THE SOLUTION FROM THE TEXTBOOK SOLTUIONS PAGE**
** THAT DOES NOT ANSWER THIS QUESTION.**

Explanation / Answer

yes there is a way to identify the correct address for a given customerId.

if you dont know the structure of the file then it becomes really difficult to know, which value is of which attribute. and we may end up displaying the city of customer when address was asked.

to solve this problem one think we can do is, create a file structure in a way that in one row you will have a data of one customer only. for next customer you will store it on next line.

for Ex. if you want to store the customerId, address, city. then these three fields must be stored on same line for same customer as below.

customerId=13324323,address=dummy address,city=dummycity

in this way, we will store the values in key value pairs seperated by '=' and each pair would be seperated from each other by means of comma(,).

so as per question we have to display the customer details when customerid is entered by user pls see the below psudocode.

1. read customerId(entered by user).

2. open the File

2. loop for i=1 to File.getLineCount()

a. line=File.readNextLine().

b. customerIdFromFile=line.getValue("customerId");

c. if(customerId=customerIdFromFile)

i. display line.getValue("address");

ii. display line.getValue("city")

3. loop ends

getValue() method:

this method will simply take the key as argument and search in the line where that key is present and corresponding value is returned.

File.getLineCount():

this method will return count of number of lines in file.

thanks & regards

please feel free to give thumbs up for my efforts.

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