|
|
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.
|
|

01-25-2008, 09:42 AM
|
 |
Member
|
|
Join Date: Jan 2008
Location: Singapore
Posts: 24
|
|
|
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.
|
|

01-25-2008, 09:55 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
|
|
Originally Posted by Clemenza1983
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.
|
|

01-25-2008, 10:03 AM
|
 |
Member
|
|
Join Date: Jan 2008
Location: Singapore
Posts: 24
|
|
|
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.
|
|

01-25-2008, 10:09 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
|
|
|
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.
|
|

01-25-2008, 11:28 AM
|
 |
Member
|
|
Join Date: Jan 2008
Location: Singapore
Posts: 24
|
|
|
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!!!
|
|

01-25-2008, 11:48 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
|
|
|
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.
|
|

01-25-2008, 11:50 AM
|
 |
Member
|
|
Join Date: Jan 2008
Location: Singapore
Posts: 24
|
|
|
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.
|
|

01-25-2008, 11:57 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
|
|
Ste the following ling, 3. Initialize Total_Age = 0
Then,
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.
|
|

01-25-2008, 11:59 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
|
|
|
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.
|
|

01-25-2008, 12:01 PM
|
 |
Member
|
|
Join Date: Jan 2008
Location: Singapore
Posts: 24
|
|
|
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.
|
|

01-25-2008, 12:02 PM
|
 |
Member
|
|
Join Date: Jan 2008
Location: Singapore
Posts: 24
|
|
|
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.
|
|

01-25-2008, 12:06 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
|
|
Originally Posted by Clemenza1983
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.
|
|

01-25-2008, 12:11 PM
|
 |
Member
|
|
Join Date: Jan 2008
Location: Singapore
Posts: 24
|
|
|
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.
|
|

01-25-2008, 12:16 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
|
|
Here is much simpler way I can come across with your question.
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.
|
|

01-25-2008, 12:17 PM
|
 |
Member
|
|
Join Date: Jan 2008
Location: Singapore
Posts: 24
|
|
|
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!
|
|

01-25-2008, 12:18 PM
|
 |
Member
|
|
Join Date: Jan 2008
Location: Singapore
Posts: 24
|
|
|
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.
|
|

01-25-2008, 12:21 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
|
|
Originally Posted by 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.
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.
|
|

01-25-2008, 12:23 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
|
|
Originally Posted by 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.
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.
|
|

01-25-2008, 06:49 PM
|
 |
Member
|
|
Join Date: Jan 2008
Location: Singapore
Posts: 24
|
|
|
Thank You very much Eranga you the man!!!
Hope to become a good programmer someday hehe
|
|

01-26-2008, 07:23 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
| | | |