Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Need to make a program to take in monthly rainfalls to an array and output certain info from that array. so lost.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
t2xplosions




PostPosted: Sat Dec 10, 2016 2:29 am   Post subject: Need to make a program to take in monthly rainfalls to an array and output certain info from that array. so lost.

What is it you are trying to achieve?
I have this question for class, and the only things I know how to do is make the array.

Create an array named "month and initialize the elements with "Jan" "Feb", etc. to "Dec". Use a
for loop to prompt for the monthly rainfall for each of the months, then use a second for loop to
print a report of the monthly rainfall. If a month's rainfall is in the top 3 rainfall months,
append a short "bring an umbrella" note beside the month.

Below this report, print the month with the least rainfall (with the amount), the month with the most
rainfall (with the amount), the average rainfall, and the total (annual) rainfall.>


What is the problem you are having?
How do I "initialize the elements"? Or move the items in one array to another? Or find the rainfalls which are the highest/lowest if everything's in an array and I can't use "if x>y statements"? Or calculate the average/total of everything in an array?


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Basically the only thing that I can figure out.

Turing:


var months : array 1..12 of string



Please specify what version of Turing you are using
Turing version 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
NightOwl




PostPosted: Sat Dec 10, 2016 9:42 pm   Post subject: Re: Need to make a program to take in monthly rainfalls to an array and output certain info from that array. so lost.

Hi there,

You might want to check this out:

http://compsci.ca/v3/viewtopic.php?t=14333

Specifically, it tells you about how to initialize the elements (Look for the code snippet under section "Passing Arrays as Arguments") and a few other basic things you need to know to work with arrays. Look especially at the usage of for loops and how it lets you "go through" all the elements of an array. All the solutions in your 2nd, 3rd, and 4th questions need to use the for loop. Once you have a better idea about that, this problems shouldn't be too hard.

Let me know if you are still confused.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: