Nov 29, 2022
Reaction score

I have some tasks to do and I have no idea how should make them. There they are:

1. Function A3Q6 takes two float arguments the first is the size of the loan. For example, £9000. This then subtracts the second argument, payments. For example, £100 leaving £8900. It then computes interest by multiplying by 2.4% ( or 0.0024f ) and adding to the loan amount (in this example, interest is £213.6). It then adds it to the loan ( giving £93113.6) and return it. Write the code for the function, which will accept any number for loan size and payment, then returns the new loan amount. Make sure your function is public.

2. Take the function provided for A3Q7. This takes the argument, which then computes the interest paid on loan given some fixed payment ( see A3Q6 ) . It repeats this calculation for the number of years argument yrs. It then returns the amount of the loan at this value.

3. Create a public global variable outside any function/method. It should be called precisely A3Q8; it must be an array of type int (integer). It should have 10 items from 1 to 10 ( 10,20,30…). Note there is no function/method required here. Make sure the variable is public.

4. The function A3Q9 is not given in the test template. Make a new public function which must be called A3Q9 this function takes no arguments and returns your name in a string.

5. The function A3Q10 is not given in the test template. Make a new public function which must be called A3Q10 this function takes an array of Strings and returns an string. It converts a list of strings into their camel case equivalent. Camel case is a typographical convention in programming. Initial capital is used for the first letter of a word forming the second element of a closed compound, e.g. iPhone, eBay, PayPal. For example, if the array passed in has the strings ["add", "tax", "to", "this","total"] it should return the string "addTaxToThisTotal". So the first string is all lower case and the rest begin with an uppercase letter string. You will have to solve this problem yourself, but look up the methods/functions on strings here ( https://docs.oracle.com/javase/7/docs/api/java/lang/String.html) which you can use to help you. .
You can call the variables anything you like.
Make sure your function is public like the others.

6. The function A3Q11 is not given. should take the arrayList of strings and an arrayList of Integers and println each one out to the console area. So the first line printed should contain the first element of the number arrayList followed by the first element of the string arrayList and so on.. So if the given arrayLists are { “Hello”, “World” } and { 19, 63 } , it should print
19 Hello
63 World
Make sure your function is public.

7. It is common for criminals to try to sell goods on eBay, Facebook Marketplace, Gumtree, etc. As a digital forensics expert, you are writing code that will search for a serial number ( which will be given as a String called target ) in a list of descriptions automatically taken from a website. In the function A3Q12 take an array of Strings (the descriptions) and a target serial number (also a String), and returns the location of the first "hit" (and -1 if there are no hits). So if the array contains {"PS5", "iPhone serial 395343340", "nice bike serial 4400020022", and the target serial number you are looking for is "4400020022", the code should return 2 (remember, items are indexed from zero).

8. For A3Q13 Drug dealers commonly use mobile phones to store details of their operations. You have been given 147 mobile phones from a ‘county lines’ operation. The phones are yours for 24 hours before the suspects in question are released unless there is some evidence against them. It would take a human about an hour to read all the messages on a phone and there is only one of you with the legal clearance to actually look at a phone. You are looking for anything suspicious. You are given an array of Strings read from a file. You want to know the line number of the message which is incriminating. If nothing is incriminating return -1. Incriminating messages are ones containing “hash” or “Fenton” take the give function A3Q13 and return the first line with this incriminating message in.

9. It's best to submit your code before attempting these. These are more 'real world' interview style questions.
Challenge 1. Keypress. This is a simplified version of an interview question. You are given a function A3Q14. This function takes an array of times in microseconds of when a user presses a key. You have to compute how long between each keypress there was. The time gap is then put into a new array which you have to make yourself. This array of gaps/durations is the one that is returned. So if the array contains [ 0,10,100, 200, 230] your return array should return [ 10,90, 100, 30 ]. You can assume that time always go up so item array[x] <= array[x+1 ].

10. Challenge 2 This is practical – the kind of thing you would write for an actual website and an interview question. You are given a string containing a phone number from the front end. Your function A3Q15 function returns true if the String is valid (an actual phone number ) or false if it is wrong in any way. Real phone numbers cannot have any letter of the alphabet ("flat face" or "043 Doge" is NOT a phone number ). You may assume that a valid phone number must appear in one of the following two formats: (xxx) xxx-xxxx or xxx-xxx-xxxx. (x means a digit, - means dash or space. So (123) 321-3332 is valid. (543-222-4323) is valid (34) 23-22 is not. Note for the (xxx) xxx-xxxx pattern there is a space after the ‘)’ Don't use a RegEx to do this !

I'd like to understand these tasks so I would appreciate any help. Thank you!

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Latest member

Latest Threads