Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-25-2008, 09:42 AM
Clemenza1983's Avatar
Member
 
Join Date: Jan 2008
Location: Singapore
Posts: 24
Clemenza1983 is on a distinguished road
Send a message via MSN to Clemenza1983
I need help
Hi All,

I am new to Java programming have not even started yet i am already stuck at doing pseudo-code. I have this assignment coming up require me to write a pseudo-code:

Can anyone please give my code a check coz i really clueless now.
--------------------------------------------------------------------------
Given a student file, you need to complete the following logical design task by using pseudo code:

1)Display the details of the students who are from Indonesia and study Multimedia

2)Show the total number of students of above student

3)Show the total number of female students in the file

4)show the average age of all the students
--------------------------------------------------------------------------
1. Initialize Total_Std_Count = 0
2. Initialize Total_Female_Std = 0
3. Initialize STD_NO = 0

4. OPEN STUDENT_FILE

5. READ a Record (NATIONALITY, SUBJECT, AGE, GENDER)

6. LOOP UNTIL end of file

7. IF every "NATIONALITY" matches "Indonesia" AND
8. IF every "SUBJECT" matches "Multimedia" THEN
Add 1 to Total_Std_Count
DISPLAY TOTAL_STD_COUNT
9. ELSE
DISPLAY "NO_STD_RECORD_FOUND"

10. ENDIF

11. IF every Gender = Female THEN
Add 1 to Total_Female_Std
DISPLAY Total_Female_Std
ELSE
DISPLAY "NO RECORD FOUND"

I got stuck at the calculate avg age. I do not know whether the above code is correct. Please do enlighten me thanks all.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-25-2008, 09:55 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by Clemenza1983 View Post
I got stuck at the calculate avg age. I do not know whether the above code is correct. Please do enlighten me thanks all.
Welcome to the Java forum

Seems your code is not bad. In the above case, to calculate average age, you have to find the sum of all students age and number of students. You find that you have to LOOP until end-of-file found, that's correct. So where why are you stuck. Just find those details within the loop.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-25-2008, 10:03 AM
Clemenza1983's Avatar
Member
 
Join Date: Jan 2008
Location: Singapore
Posts: 24
Clemenza1983 is on a distinguished road
Send a message via MSN to Clemenza1983
So do you imply that my code is on the right track, coz somehow i just feel that is somewhere out of the way. Am i correct to link all these codes together? Sorry really new to this really need alot of guidance. Thanks appreciated.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-25-2008, 10:09 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yes, but in implementing you can change the way appropriately. Best thing is start work right now and if you stuck, get back to here.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-25-2008, 11:28 AM
Clemenza1983's Avatar
Member
 
Join Date: Jan 2008
Location: Singapore
Posts: 24
Clemenza1983 is on a distinguished road
Send a message via MSN to Clemenza1983
Still do not get it.
Hi there all ppl out there can anyone please guide me on this i really need guidance after search and reading thru i still confuse on how to actually do a good pseudocode. Gosh please i need help!!!
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-25-2008, 11:48 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ok pal, now what is your question. The previous code is correct actually. And at the same time different people can seen it in different views. Now where are you stuck.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 01-25-2008, 11:50 AM
Clemenza1983's Avatar
Member
 
Join Date: Jan 2008
Location: Singapore
Posts: 24
Clemenza1983 is on a distinguished road
Send a message via MSN to Clemenza1983
I am stuck at the average student age, can i put it this manner?

STD_NO STD_NAME GENDER AGE SUBJECT NATIONALITY
---------------------------------------------------------------------------
1001 Albert Male 20 Programing England
1002 Boey Male 21 Engineering Indonesia
1003 Chan Mei Ling Female 21 Graphic Design China
1004 Dahnia Female 22 Networking India
1005 Melanie Female 23 Multimedia Philipines
1006 Yung Hua Male 24 Multimedia Indonesia
1007 Gerry Male 24 Multimedia Indonesia
1008 Canny Liew Female 24 Networking Malaysia
1009 Ben Low Male 26 Programing Singapore
================================================== =========================

1. Initialize Total_Std_Count = 0
2. Initialize Total_Female_Std = 0
3. Initialize Age =

4. OPEN STUDENT_FILE

5. READ a Record (NATIONALITY, SUBJECT, AGE, GENDER)

6. LOOP UNTIL end of file

7. IF every "NATIONALITY" matches "Indonesia" AND
8. IF every "SUBJECT" matches "Multimedia" THEN
Add 1 to Total_Std_Count
DISPLAY TOTAL_STD_COUNT
9. ELSE
DISPLAY "NO_STD_RECORD_FOUND"

10. ENDIF

11. IF every Gender = Female THEN
Add 1 to Total_Female_Std
DISPLAY Total_Female_Std
ELSE
DISPLAY "NO RECORD FOUND"

12. ENDIF

13. IF STD_NO < 1010 THEN
Add 1 to Total_Std_Count
ELSE DISPLAY "ERROR"
14. How to i add the age? Please help me here thanks.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 01-25-2008, 11:57 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ste the following ling, 3. Initialize Total_Age = 0

Then,

Code:
If every "AGE" is greater than zero Total_age = Total_Age + AGE
No need of else part actually. If you you can use a 'else' to display an error, like Age can't be valid or something like that. Is it helpful to you?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 01-25-2008, 11:59 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Since you have number of students, you can find the average as follows

Initialize AVG = 0
AVG = Total_Age / Total_Std_Count
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 01-25-2008, 12:01 PM
Clemenza1983's Avatar
Member
 
Join Date: Jan 2008
Location: Singapore
Posts: 24
Clemenza1983 is on a distinguished road
Send a message via MSN to Clemenza1983
Oh yes it is very helpful thank you so much. It the logic that i have to get use 2 but it seems like my brain have lots of things already and my workload is getting too much for me to handle

IF Study and Work < Time
DISPLAY "TIRING"

hehe how i wish i can have someone to discuss these things with.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 01-25-2008, 12:02 PM
Clemenza1983's Avatar
Member
 
Join Date: Jan 2008
Location: Singapore
Posts: 24
Clemenza1983 is on a distinguished road
Send a message via MSN to Clemenza1983
But first i have to add up all the ages that is the part which i do not understand but thanks anyway Eranga for your reply really appreciate it.
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 01-25-2008, 12:06 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by Clemenza1983 View Post
But first i have to add up all the ages that is the part which i do not understand
That's what I have done in my 8[sup]th[/sup] post. Is it not clear for you?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 01-25-2008, 12:11 PM
Clemenza1983's Avatar
Member
 
Join Date: Jan 2008
Location: Singapore
Posts: 24
Clemenza1983 is on a distinguished road
Send a message via MSN to Clemenza1983
What i dun understand is
If every "AGE" is greater than zero
(Total_age = Total_Age + AGE) --> this is the part i do not understand.

Can pls explain how you get Total Age may be a silly question but i just do not understand this part.

Do you have msn messenger? I know it inappropriate for me to ask this.
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 01-25-2008, 12:16 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Here is much simpler way I can come across with your question.

Code:
1. Initialize Total_Std_Count = 0 2. Initialize Total_Female_Std = 0 3. Initialize Total_Age = 0 4. Initialize Avg = 0 5. OPEN STUDENT_FILE 6. READ a Record (NATIONALITY, SUBJECT, AGE, GENDER) 7. LOOP UNTIL end of file 8. IF every "NATIONALITY" matches "Indonesia" AND every "SUBJECT" matches "Multimedia" THEN Add 1 to Total_Std_Count 9. ELSE DISPLAY "NO_STD_RECORD_FOUND" 10.IF every Gender = Female THEN Add 1 to Total_Female_Std 11.ELSE DISPLAY "NO_RECORD_FOUND" 12.IF every "AGE" is greater than zero Then Add AGE to Total_Age 13.ELSE DISPLAY "Invalid age" 14.DISPLAY Total_Std_Count 15.DISPLAY Total_Female_Std 16.CALCULATE AVG as Total_Age devide by Total_Std_Count 17.DISPLAY AVG
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 01-25-2008, 12:17 PM
Clemenza1983's Avatar
Member
 
Join Date: Jan 2008
Location: Singapore
Posts: 24
Clemenza1983 is on a distinguished road
Send a message via MSN to Clemenza1983
I am going for my night class now i will be back later anyway thanks eranga you are the first to reply to my question i really appreciate it hope to hear from you soon as a friend. Out!
Bookmark Post in Technorati
Reply With Quote
  #16 (permalink)  
Old 01-25-2008, 12:18 PM
Clemenza1983's Avatar
Member
 
Join Date: Jan 2008
Location: Singapore
Posts: 24
Clemenza1983 is on a distinguished road
Send a message via MSN to Clemenza1983
Thank you i am sure i be able to work these out coz i also do not wish to copy these step i wanna find out the logic out myself or else there is no point in studying java haha you been of great help.
Bookmark Post in Technorati
Reply With Quote
  #17 (permalink)  
Old 01-25-2008, 12:21 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by Clemenza1983 View Post
What i dun understand is
If every "AGE" is greater than zero
(Total_age = Total_Age + AGE) --> this is the part i do not understand.

Can pls explain how you get Total Age may be a silly question but i just do not understand this part.

Do you have msn messenger? I know it inappropriate for me to ask this.
Ok, first I initialized Total_Age to zero. Then you read the file, say line by line. At the reading time you can find the age of each student. I think it is clear.

Say first student age is 20, then
Total_Age = 0 + 20 --> Result is 20

Say second student age is 15, then
Total_Age = 20 + 15 --> Result is 35

I have put a condition, age greater than zero. Because no one can have zero age. Is it clear to you.

BTW, if you can use my Yahoo messenger. You can see it my profile.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #18 (permalink)  
Old 01-25-2008, 12:23 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by Clemenza1983 View Post
Thank you i am sure i be able to work these out coz i also do not wish to copy these step i wanna find out the logic out myself or else there is no point in studying java haha you been of great help.
Yep, learn the basis well first. Mainly the logic of each problem you come across with.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #19 (permalink)  
Old 01-25-2008, 06:49 PM
Clemenza1983's Avatar
Member
 
Join Date: Jan 2008
Location: Singapore
Posts: 24
Clemenza1983 is on a distinguished road
Send a message via MSN to Clemenza1983
Thank You very much Eranga you the man!!!
Hope to become a good programmer someday hehe
Bookmark Post in Technorati
Reply With Quote
  #20 (permalink)  
Old 01-26-2008, 07:23 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412