•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Computer Science and Software Design section within the Software Development category of DaniWeb, a massive community of 397,750 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,594 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Computer Science and Software Design advertiser:
Views: 3825 | Replies: 2
![]() |
•
•
Join Date: Apr 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hi to all
I have just joined this lovely community today. I was wondering if someone would be willing to help out a newbie gal with a pseudocode problem....
Basically I am trying to write some pseudo code for the following problem
- A company has some data for each month for five years which = 60 integers
(12 integers for each year)
- A program must prompt the user to input the data and warn if the data is not an integer
- The program must calculate the average for each year and display it for each year (e.g. year 1, year 2, year 3, year 4, year5)
I have come with the following but am not sure if it's correct - I can see 2 flaws
1. There are 5 wasteful loops which capture virtually the same information
2. Also I feel that perhaps I should use an array to store the 60 integers
begin
Integer i, yr1, yr2, yr3, yr4, yr5
// Loop to get values of Year 1
i=1
REPEAT
Display “Enter values for Year 1 as integers�
IF value = integer THEN
Display “Confirm data entry finished�
ELSE
Display “Values entered not integers, re-enter as integers�
END IF
i = i+1
UNTIL (i<12)
// The value Yr 1 is equal to the sum of the values of all the months for Year 1
Yr1 = sum of i1+i2+ i3 +i4+i5+i6+i7+i8+i9+i10+i11+i12
// Call procedure to calculate average for Year 1, procedure is at end of program
Call Average (yr1)
Display “Average growth for Year 1 is� + Average
end
begin
// The program continues with another 4 loops same as the one above to capture the data for each year.
// I didn't include the four other loops in my example because I thought that this is a lot of repitition
________________________________________________________
Procedure to calculate Average for each year
begin
AVERAGE (integer yr)
AVERAGE = yr/12
end
Any advice would be very much appreciated.
Thank you in advance....
Cheers
Potsuki :p
I have just joined this lovely community today. I was wondering if someone would be willing to help out a newbie gal with a pseudocode problem....
Basically I am trying to write some pseudo code for the following problem
- A company has some data for each month for five years which = 60 integers
(12 integers for each year)
- A program must prompt the user to input the data and warn if the data is not an integer
- The program must calculate the average for each year and display it for each year (e.g. year 1, year 2, year 3, year 4, year5)
I have come with the following but am not sure if it's correct - I can see 2 flaws
1. There are 5 wasteful loops which capture virtually the same information
2. Also I feel that perhaps I should use an array to store the 60 integers
begin
Integer i, yr1, yr2, yr3, yr4, yr5
// Loop to get values of Year 1
i=1
REPEAT
Display “Enter values for Year 1 as integers�
IF value = integer THEN
Display “Confirm data entry finished�
ELSE
Display “Values entered not integers, re-enter as integers�
END IF
i = i+1
UNTIL (i<12)
// The value Yr 1 is equal to the sum of the values of all the months for Year 1
Yr1 = sum of i1+i2+ i3 +i4+i5+i6+i7+i8+i9+i10+i11+i12
// Call procedure to calculate average for Year 1, procedure is at end of program
Call Average (yr1)
Display “Average growth for Year 1 is� + Average
end
begin
// The program continues with another 4 loops same as the one above to capture the data for each year.
// I didn't include the four other loops in my example because I thought that this is a lot of repitition
________________________________________________________
Procedure to calculate Average for each year
begin
AVERAGE (integer yr)
AVERAGE = yr/12
end
Any advice would be very much appreciated.
Thank you in advance....
Cheers
Potsuki :p
•
•
Join Date: Dec 2004
Location: Allentown, PA
Posts: 60
Reputation:
Rep Power: 4
Solved Threads: 1
I think that your "pseudocode" suffers from imprecision. If you tried to turn it into code in some language that you know (C, Pascal, Basic, or whatever) you'd see the problem. You could also check it out by making up a data set and try carrying out the exact program steps yourself. I think you'd see that it's ambiguous.
One example near the beginning will demonstrate the point. You use the test "if value = integer". "value' is not one of your variables. If you read one input varaible and it's not an integer are you supposed to re-enter that value or do you have to enter the 12 values for that year?
One example near the beginning will demonstrate the point. You use the test "if value = integer". "value' is not one of your variables. If you read one input varaible and it's not an integer are you supposed to re-enter that value or do you have to enter the 12 values for that year?
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Computer Science and Software Design Marketplace
•
•
•
•
applications blog business software computer database dell design developer development erp systems howto illustrator india intel internet it java linux malware media microsoft mmorpg networking news normalization office open operating photoshop pricing programming project management rss science search security software software selection source spyware system technology evaluation tips toread vista web wiki windows xp
- Pseudocode (Computer Science and Software Design)
- Questions about building a system (was: newbie) (Troubleshooting Dead Machines)
- As a newbie, where i should start from in linux? (Getting Started and Choosing a Distro)
- PHP newbie, project feasibility (PHP)
- Program design tools (C++)
- How to network two Win98 machines (Networking Hardware Configuration)
Other Threads in the Computer Science and Software Design Forum
- Previous Thread: How to create a listing bot?
- Next Thread: Reverse Engineering



Linear Mode