![]() |
|
|||||||
| Notices |
| Programming Forum Web and Software Programming Forum - Java, PHP, SQL etc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Right not shown my face around for some time, but hey I'm back.
I really need some help with an assignment for Uni, its a programming one and the programme was written by the lecturer. It is very similar to Visual Basics, the assignment is due in on Thursday by 5pm and I really need the help, if anyone is up for giving me a hand that would be great cos i realy can't fail this module as I'm doing so well in everything else except this......! Cheers Matt
__________________
======================================== But Seriously, Hands up if you Love CSS.....! ======================================== MattFaucher.co.uk MattFaucher.me.uk |
|
|
|
||||
|
Post it up and someone can take a look :P
__________________
CM Designs - Under Development | My Art Site |
|
||||
|
These are ref sheets, assignment way down the bottom:
Bugz Operator reference The String family Concat Joins two strings together. String.Concat "foo" "bar" returns "foobar" String.Concat "bar" "foo" returns "barfoo" FindFirst Finds the first position of one string inside another, counting from zero. String.FindFirst "foobarbar" "bar" returns 3 String.FindFirst "hello world" " " returns 5 FindLast Finds the last position of one string inside another, counting from zero. String.FindLast "foobarbar" "bar" returns 6 String.FindLast "foo bar bar" " " returns 7 GetAt Returns the character from a specified position within a string. String.GetAt "abcd" 2 returns 'c' String.GetAt "abcd" 0 returns 'a' SetAt Sets the character at a given position to a new value. String.SetAt "abcd" 2 'X' returns "abXd" String.SetAt "abcd" 3 'X' returns "abcX" Insert Inserts one string inside another at a given position. String.Insert "foo" 1 "bar" returns "fbaroo" String.Insert "foo" 0 "bar" returns "barfoo" Length Returns a count of the number of characters in a string. String.Length "foobar" returns 6 String.Length "" returns 0 Substring Returns a substring of a given length, from a given position. String.Substring "foobarbaz" 3 4 returns "barb" String.Substring "foobarbaz" 0 4 returns "foob" ToInteger Converts a string of digits into the corresponding Integer String.ToInteger "1234" returns 1234 String.ToInteger "-12" returns -12 ToUpper Returns the upper case equivalent of a string. String.ToUpper "FOObar" returns "FOOBAR" String.ToUpper "FOObar123" returns "FOOBAR123" ToLower Returns the lower case equivalent of a string. String.ToLower "FOObar" returns "foobar" String.ToLower "FOObar123" returns "foobar123" TrimEnd Removes any white space from the end of a string. String.TrimEnd "foo " returns "foo" TrimStart Removes any white space from the beginning of a string. String.TrimStart " foo" returns "foo" Expressions An expression is a code fragment that is contained between a matching pair of parentheses. Expressions are used as a shortcut notation for commonly occurring code. An expression must start with an open parenthesis and finish with a close parenthesis. Some examples are: Arithmetic expressions An arithmetic expression will always return a number. (2 + 6) // Add two numbers (2 + 6 + 8) // Add three numbers (3 + 8 * 4) // Add 3 to the product of 8 and 4 ((3+8) * 4) // Multiply the sum of 3 and 8 by 4 (6 - 2) // Subtract 2 from 6 (9 / 2) // Divide 9 by 2 and round down to an integer (10 % 3) // calculate the remainder when 10 is divided by 3 Boolean expressions A Boolean expression will always return a Boolean value - true or false. (1 < 2) // Tests if 1 is less than 2 (2 >= 1) // Tests if 2 is greater than or equal to 1 (a <= b) // Tests if the value in a is less than the value in b (a > b) // Tests if a is greater than b (a == b) // Tests if a is equal to b (C style syntax) (a = b) // Tests if a is equal to b (Visual basic style syntax) (a != b) // Tests if a is not equal to b (C style syntax) (a <> b) // Tests if a is not equal to b (VB style syntax) (a < b && c < d) // Tests if a is less than b and c is less than d (C style syntax) (a < b and c < d) // Tests if a is less than b and c is less than d (VB style syntax) (a < b || c < d) // Tests if a is less than b or c is less than d (C style syntax) (a < b or c < d) // Tests if a is less than b or c is less than d (VB style syntax) (!(a < b)) // Tests the opposite of a is less than b (C style syntax) (not (a < b)) // Tests the opposite of a is less than b (VB style syntax) String expressions The main use for string expressions is to provide a short way of concatenating several strings. ("foo" + "bar") // same as String.Concat "foo" "bar" (C style syntax) ("foo" + "bar" + "bovril") // Same as String.Concat "foo" String.Concat "bar" "bovril" (C style syntax) ("foo" & "bar") // Same as String.Concat "foo" "bar" (VB style syntax) ("foo" & "bar" & "bovril") // Same as String.Concat "foo" String.Concat "bar" "bovril" (VB style syntax) Expressions involving operators Almost any built-in or user-defined operator can appear in an expression, provided that its parameters are themselves listed between a pair of parentheses, and separated by commas. (String.Substring("Hello", 0, 4)) (String.Substring(s, 0, String.Length(s) - 1)) (String.Insert("foobar", 3, Convert.IntegerToString(1234))) Syntax errors The error message "Syntax error in expression" occurs whenever an badly formed expression is found in the program text. The more complex an expression, the more likely it is to be badly formed. Some examples of badly formed expressions are: (2 *+ 4) ( + 9) (8 9) -------------------------------------------------------------------------- Assignment The tasks 1. Write a procedure called cube and try it out as follows. n= 3 User.Cube &n Console.WriteLine n.ToString // output should be 27 n= 5 User.Cube &n Console.WriteLine n.ToString // output should be 125 [5 marks] 2. Here is a program that uses a procedure called User.Power. It should output the number 16 (2 raised to the power 4), and then 64 (4 raised to the power 3). Implement User.Power. Hint: you will need a loop. [5 marks] n= 2 User.Power &n 4 Console.WriteLine n.ToString m= 4 User.Power &m 3 Console.WriteLine m.ToString [5 marks] 3. Complete the implementation of the bank simulation in the supplied file bank.nfj. If a user of the bank tries to withdraw more money than is in the current balance, the operation should be refused and the message "Insufficient funds" displayed in the Console. You must complete the implementation of User.Withdraw and make use of it in your main program. [5 marks] 4. Complete the implementation of a new procedure called User.ArrayDouble. This takes two parameters, the address of the base store of an array, and the size of the array. It doubles each number stored in the array. Use the supplied file ArrayDouble.nfj. [10 marks] 5. Complete the implementations of the user defined operators User.ArrayMax and User.ArrayMin. These take an array base and size as parameter and return the largest and smallest items in the array respectively. Use the file ArrayMaxMin.nfj. [10 marks] 6. Date project [65 marks] To complete this exercise you will need to complete the implementations of several user defined operators in the file dateproject.nfj. The specifications are as follows: User.GetDay Takes a string of the form day/month/year and returns the number that represents the day. For example: User.GetDay "23/12/2008" should return 23 User.GetDay "2/4/2009" should return 2 [0 marks: from previous assignment] User.GetMonth Takes a string of the form day/month/year and returns the number that represents the month. For example: User.GetMonth "23/12/2008" should return 12 User.GetMonth "2/4/2009" should return 4 [0 marks: from previous assignment] User.GetYear Takes a string of the form day/month/year and returns the number that represents the year. For example: User.GetYear "23/12/2008" should return 2008 User.GetYear "2/4/2009" should return 2009 [0 marks: from previous assignment] User.MakeDate Takes three numbers representing the day month and year of a date, and returns the string representation. For example: User.MakeDate 23 12 2008 should return "23/12/2008" User.MakeDate 2 4 2009 should return "2/4/2009" [5 marks] User.DaysInMonth Takes two numbers representing a month and a year, and returns the number of days in that month in that particular year. You can assume that a leap year is one divisible by 4. For example: User.DaysInMonth 2 2000 returns 29 //leap year User.DaysInMonth 2 2001 returns 28 // not a leap year User.DaysInMonth 1 1999 returns 31 // 31 days in January User.DaysInMonth 4 1999 returns 30 // 30 days in April [10 marks] User.NextDay Takes a string that represents a date, and returns a string that represents the date of the following day. For example: User.NextDay "28/2/2000" returns "29/2/2000" User.NextDay "28/2/2001" returns "1/3/2001" User.NextDay "31/12/2000" returns "1/1/2001" [10 marks] User.DateAdd Takes a string that represents a date and a positive number, and returns a string that represents the date the given number of days after the date. For example: User.DateAdd "1/1/2002" 365 returns "1/1/2003" User.DateAdd "1/1/2000" 365 returns "31/12/2000" [10 marks] User.DateDifference Takes two strings representing dates, and returns the number of days between the two dates. For example: User.DateDifference "1/1/2000" "1/1/2001" returns 366 User.DateDifference "1/1/2006" "1/1/2005" returns 365 [10 marks] Finally, write a main program that thoroughly tests each of the operators you have implemented. [20 marks] -------------------------------------------------------------------------- This may just look like a mess as I havejus cut and pasted it, if anyone thinks they can help I can email you the stuff (zipped up) Again Thanks Matt
__________________
======================================== But Seriously, Hands up if you Love CSS.....! ======================================== MattFaucher.co.uk MattFaucher.me.uk |
![]() |
|
|
| Thread Tools | |
| Display Modes | |
|
|
| All times are GMT. The time now is 05:34 AM. |