File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Need help with Pseudocode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need help with Pseudocode" Watch "Need help with Pseudocode" New topic

Need help with Pseudocode

Qriz Cruega

Joined: Nov 01, 2012
Posts: 11

Hi everybody,

I recently learned here, in this excellent forum, about the importance of Pseudocode, and I hope for some feedback to make sure I'm on the right track.

I think my current assignment is formulated pretty java-ese, which makes it hard for me to produce proper pseudocode.(afaict)

Here is the assignment ( it's slightly modified to not get in trouble)

Create a class named MotelRoom that includes an integer field for the room number and a
double field for the nightly rental rate. Include get methods for these fields and a
constructor that requires an integer argument representing the room number. The
constructor sets the room rate based on the room number; rooms numbered 299 and
below are $59.95 per night, and others are $79.95 per night. Create an extended class
named Suites whose constructor requires a room number and adds a $30 surcharge to
the regular hotel room rate, which again is based on the room number. Write
an application named UseMotelRoom that creates an object of each class, and demonstrate
that all the methods work correctly. Save the files as,,

Here is what I came up with:


Prepare 3 sheets of paper.
Title the first paper Motelrooms.
Write down rates on first paper.
Write down scope of room numbers on first paper.
(less than 300, greater than 299)
Write boolean rule to determine room price.
Title the second paper Suites.
Copy first paper on to second paper.
Add surcharge to rates of second paper.
Title the third paper UseMotelrooms.
Copy both pages on to third paper.
Add question for room number on third paper.
Reference the first paper and choose the right rate.
Reference the second paper and add the surcharge.
Send to printer.

Feedback is greatly appreciated

Steve Luke

Joined: Jan 28, 2003
Posts: 4181

I think you are tying to use pseudocode for more that what it is good at. Pseudocode is great for writing out an algorithm so you know the steps required to do something. So you might use pseudocode to describe the discreet steps that need to be done when a MotelRoom is created, and another chunk to describe the steps needed in the main method in order to create and test the classes you wrote.

But for an overall design, it doesn't work so well. Instead, you should use a 'Class Diagram' (see Class_Diagram for some details. Now, there is a lot there and you don't need it all yet, but you should get the basics of being able to draw out the class and make arrows for what extends what, and who uses whom.

Here is an example (not using your example so that you could do that yourself):

Model a university class that has an ID for the course (example "BIO101") the ID (an integer) of the professor teaching the course, and the number of students in the course (also an integer). There should be a method to add students to the course, and one to get the teacher's ID.

Additionally, there is a type of advanced course which also has a lab, it should extend the bas course and add a field for the number of lab hours in the course. There should be a method to get the number of lab hours.

I will use an informal approach to the class diagram now which is expressive without being to demanding on syntax (good until you learn UML or your teacher teaches you more).

Then for any of the methods I would have to write out in pseudocode what they are supposed to do. And remember, keep the steps in pseudocode super short, single baby steps and as specific as possible because that will translate into code better and help define the variables that you need.

Qriz Cruega

Joined: Nov 01, 2012
Posts: 11

Steve Luke wrote: Instead, you should use a 'Class Diagram' (see Class_Diagram for some details.

Thanks I will look into that.
I agree. Here's the link:
subject: Need help with Pseudocode
It's not a secret anymore!