Welcome to Dream.In.Code
Become a Java Expert!

Join 149,508 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,338 people online right now. Registration is fast and FREE... Join Now!




Pseudocode help please

 
Reply to this topicStart new topic

Pseudocode help please

ravensrock86
11 Jul, 2007 - 05:33 AM
Post #1

New D.I.C Head
*

Joined: 11 Jul, 2007
Posts: 21


My Contributions
Hi, I'm taking my first course in java and I'm about midway through the class. I've just received my first project. It asks me to write a pseudocode for the coding. I understand the coding part alright, but I'm completely stumped on what to do for the pseudocode. We went over pseudocode really quickly in class and my brain didn't process the information all that well sad.gif I've looked at some of the examples on pseudocode on this forum, but they are just too complex for me. Could someone please provide a sample example or two so that I can understand it better? Also could you post soon? This project is due in two days. Thanks in advance.

This post has been edited by ravensrock86: 11 Jul, 2007 - 05:33 AM
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Pseudocode Help Please
11 Jul, 2007 - 08:48 AM
Post #2

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,010



Thanked: 7 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
Hi, pseudocode the way I see it is a code that would be easy to understand for humans so, there are no rules when you write pseudo code unless you've reached some conventions in the class. I'll give an example of my pseudocode for the Hello world program

CODE
function main that returns nothing
                      start
                        print on the screen"Hello World"
                      finish


I know that doesn't look like the pseudocode you've expected, but as I said pseudocode is a code that doesn't compile so you are free to write the problem the way you understand it.

This post has been edited by PennyBoki: 11 Jul, 2007 - 08:48 AM
User is offlineProfile CardPM
+Quote Post

ravensrock86
RE: Pseudocode Help Please
11 Jul, 2007 - 12:39 PM
Post #3

New D.I.C Head
*

Joined: 11 Jul, 2007
Posts: 21


My Contributions
QUOTE(PennyBoki @ 11 Jul, 2007 - 09:48 AM) *

Hi, pseudocode the way I see it is a code that would be easy to understand for humans so, there are no rules when you write pseudo code unless you've reached some conventions in the class. I'll give an example of my pseudocode for the Hello world program

CODE
function main that returns nothing
                      start
                        print on the screen"Hello World"
                      finish


I know that doesn't look like the pseudocode you've expected, but as I said pseudocode is a code that doesn't compile so you are free to write the problem the way you understand it.


Well in that case, then I can start right away biggrin.gif I just hope that my teacher agrees with you. The pseudocode portion is worth 40% of the project. Thanks for your help.
User is offlineProfile CardPM
+Quote Post

capty99
RE: Pseudocode Help Please
11 Jul, 2007 - 12:57 PM
Post #4

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,252



Thanked: 16 times
Dream Kudos: 550
My Contributions
it is.
User is offlineProfile CardPM
+Quote Post

ravensrock86
RE: Pseudocode Help Please
11 Jul, 2007 - 01:03 PM
Post #5

New D.I.C Head
*

Joined: 11 Jul, 2007
Posts: 21


My Contributions
Just to make sure I know what I'm doing, could someone explain this sample Pseudocode that I got off my class website?

http://www.cs.umd.edu/projects/passport/Le...areDesignL5.pdf

Its page 8 that I'm looking at. don't understand what "entries = read() means" nor "prev = read()" means. unsure.gif
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Pseudocode Help Please
11 Jul, 2007 - 01:58 PM
Post #6

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,010



Thanked: 7 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
Hi, I find interesting a point in that pdf file where it says something like: If you give a person the pseudocode that person shouldn't ask you about the code or something like that. I find that statement contradictory in your case but here we go with the pseudocode:
entries = read() the user of the program should enter the value for enrties

prev = read() the user of the program should enter the value for entries
i = 1 the programmer is assigning 1 to i
valid = true the programmer is assigning true to valid
while (i < entries && valid) { while i is less than entries AND valid is true
curr = read() the user should enter value for curr
if (curr < prev) { if curr is less than prev
valid = false; set valid to false
}
prev = curr give prev the value of curr
i = i + 1 increase i by 1
}
print(“Sequence is:” print on the screen
Print(valid) call the print function with valid as an argument

This post has been edited by PennyBoki: 11 Jul, 2007 - 02:02 PM
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Pseudocode Help Please
11 Jul, 2007 - 02:14 PM
Post #7

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,010



Thanked: 7 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
QUOTE(Tyler James Lee @ 11 Jul, 2007 - 01:57 PM) *

it is.


What is?




to ravensrock86

just want to be clear: the pseudocode you are using is not the way I showed it to you in the hello world so you have just what you need in the pdf file to write a pseudocode
so the Hello World program would be

CODE
procedure printHelloWorld
{
       print("Hello World")
}

User is offlineProfile CardPM
+Quote Post

ravensrock86
RE: Pseudocode Help Please
11 Jul, 2007 - 03:21 PM
Post #8

New D.I.C Head
*

Joined: 11 Jul, 2007
Posts: 21


My Contributions
QUOTE(PennyBoki @ 11 Jul, 2007 - 02:58 PM) *

Hi, I find interesting a point in that pdf file where it says something like: If you give a person the pseudocode that person shouldn't ask you about the code or something like that. I find that statement contradictory in your case but here we go with the pseudocode:
entries = read() the user of the program should enter the value for enrties

prev = read() the user of the program should enter the value for entries
i = 1 the programmer is assigning 1 to i
valid = true the programmer is assigning true to valid
while (i < entries && valid) { while i is less than entries AND valid is true
curr = read() the user should enter value for curr
if (curr < prev) { if curr is less than prev
valid = false; set valid to false
}
prev = curr give prev the value of curr
i = i + 1 increase i by 1
}
print(“Sequence is:” print on the screen
Print(valid) call the print function with valid as an argument


Ok, that makes some sense. But I'm still confused on one thing. What does it mean when it says prev? Could you provide an example of prev using java language please?

User is offlineProfile CardPM
+Quote Post

ravensrock86
RE: Pseudocode Help Please
12 Jul, 2007 - 06:47 AM
Post #9

New D.I.C Head
*

Joined: 11 Jul, 2007
Posts: 21


My Contributions
Ok I tried to figure out the pseudocode and this is what I got:

CODE

import javax.swing.*;
public class pseudocode {
    public static void main(String[] args) {
                
        int entries = Integer.parseInt(JOptionPane.showInputDialog("Enter a value"));
        int prev = Integer.parseInt(JOptionPane.showInputDialog("Enter another value"));
        int i = 1;
        boolean valid = true;
        while (i < entries && valid == true ){
            int curr = Integer.parseInt(JOptionPane.showInputDialog("Enter a value"));
            if (curr < prev){
                valid = false;
            }
            prev = curr;
            i = i + 1;
        }
        System.out.println("Sequence is:");
        System.out.println(valid);

    }

}


Can some tell me if that is right or not?
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Pseudocode Help Please
12 Jul, 2007 - 12:33 PM
Post #10

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,010



Thanked: 7 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
I think that the code is ok except for the declaration of int curr in the while loop, just declare int curr at the beginning perhaps and it'll be fine I think.

This post has been edited by PennyBoki: 12 Jul, 2007 - 12:34 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 07:26PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month