This is the problem amd im not sure how to do it. This class from what my otherclassmates have been telling is that I should already know how to do the pseudocode. But my teacher does not explain anything but this is what I have came up with.

The Barking Lot is a dog day care center. Design the following:

1. A Dog class that holds fields for ID number of owner, an the name, breed, age, and weight of the dog. Include get and set methods for each field.

2. An Owner class that holds ID number of owner, and owner's name, address, and phone number. Include get and set methods for each field.

3. A method that accepts two objects--a Dog and an Owner. If the Dog and Owner IDs do not match, display an error message. Otherwise, display a bill containing the Owner and Dog data and the weekly day care fee which is $55 for dogs under 15 pounds, $75 for dogs at least 15 pounds but no more than 30 pounds, $105 for dogs over 30 pounds but no more than 80 pounds, and $125 for dogs over 80 pounds.


ownerDOGclass
IDnumber
Breed
Age
Weight

This is all I got. I know its not much but I dont understand it please help.

Dani AI

Generated

A clear, practical approach is to separate data (the two classes) from the billing logic. List each class with its fields and minimal methods, then write one short procedure that accepts a Dog and an Owner, verifies the IDs, computes the weekly fee, and prints a formatted bill. Keep the pseudocode readable and language-neutral so it’s easy to translate to Python later.

’s point about keeping pseudocode language-agnostic and ’s suggestion to write the logical steps first are both useful—begin in plain English, then convert to the structure below. The following pseudocode is concise and focused on the required responsibilities without implementation details.

class Dog
  fields:
    ownerID
    name
    breed
    age
    weight
  methods:
    getOwnerID()
    setOwnerID(id)
    getWeight()
    toString()   // returns dog info as a string

class Owner
  fields:
    ownerID
    name
    address
    phone
  methods:
    getOwnerID()
    toString()   // returns owner info as a string

procedure PrintBill(dog, owner)
  if dog.getOwnerID() != owner.getOwnerID() then
    print "Error: owner ID does not match"
    return
  fee = CalculateFee(dog.getWeight())
  print "----- Weekly Bill -----"
  print owner.toString()
  print dog.toString()
  print "Weekly fee: $" + fee

function CalculateFee(weight)
  if weight < 15 then return 55
  else if weight >= 15 and weight <= 30 then return 75
  else if weight > 30 and weight <= 80 then return 105
  else return 125

Quick troubleshooting tips: ensure owner IDs use the same type/format on both classes (trim whitespace if IDs come from input), compare numeric weights with inclusive boundaries (test exactly 15.0, 30.0, 80.0), and add simple unit tests: a matched ID with weight 14.9, 15.0, 30.0, 80.0, and 80.1 to confirm the fee logic. When converting to Python, implement __str__ / __repr__ (or simple to_string) for neat output and keep billing logic in a separate function for easy testing.

Recommended Answers

All 4 Replies

Pseudocode is a language-agnostic way of writing a computer problem. Its used as the step before writing the actual code for a program (sometimes) or at least a small routine/algorithm (most of the time). It depends a lot on the person who writes the pseudocode how it is formatted and how explicit it is about some things, but you should generally try to avoid using extremely language specific ideas, such as "make a vector of integers". It's usually along the lines of

Dog class:

variables (private)
number: owner's ID
string: name
string: breed
number: age
number: weight

methods (public)
getID: returns owner's ID
setID: set owner's ID

And so forth. However you want to structure it is fine, writing a program in pseudocode first is supposed to let you get the whole idea of the program, how the different parts interact and how you are going to write the program before you focus on the implementation/language dependent details such as memory allocation and management. This is the style of pseudocode that I've always used, but throughout my school career I've never had someone apply pseudocode as a rigorous science, but someone more experienced than me may know better.

Thanks anything helps. Because Im really struggling with it I have about 3 more weeks left of it and I just gave up now im trying to do it again.

Pseudocode is a language-agnostic way of writing a computer problem. Its used as the step before writing the actual code for a program (sometimes) or at least a small routine/algorithm (most of the time). It depends a lot on the person who writes the pseudocode how it is formatted and how explicit it is about some things, but you should generally try to avoid using extremely language specific ideas, such as "make a vector of integers". It's usually along the lines of

Dog class:

variables (private)
number: owner's ID
string: name
string: breed
number: age
number: weight

methods (public)
getID: returns owner's ID
setID: set owner's ID

And so forth. However you want to structure it is fine, writing a program in pseudocode first is supposed to let you get the whole idea of the program, how the different parts interact and how you are going to write the program before you focus on the implementation/language dependent details such as memory allocation and management. This is the style of pseudocode that I've always used, but throughout my school career I've never had someone apply pseudocode as a rigorous science, but someone more experienced than me may know better.

Thanks anything helps. Because Im really struggling with it I have about 3 more weeks left of it and I just gave up now im trying to do it again.

pseduocode is a way of writting down the logic with out dealing with the implementation details; it can be very code like or very english like.

for example, pseduocode for swaping the order in an array:

for i = 0 ... n/2 and j = n ... n/2 then
swap i'th element of array with j'th element of array
next

notice the implementation of is intuitivly given.

I could also have written it like

for i = 0, i < N/2, i = i + 1
temp = array
array = array[n-i]
array[n-i] = temp
next

which is also pseducode.

So basically write down the logical steps you think you need for your problem; and you've most likly written pseducode.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.