The Student Room Group

Higher computing 2014/15 coursework penny's decking

Scroll to see replies

Can someone help me? My class has just been verified and i haven't even started on the program for Penny's Decking and it's to be done in the next couple of weeks... We're doing it in Python, but i have no idea what to do because i'm terrible at programming and the teacher won't help me. :frown:
Reply 41
Original post by CharliesLapras
Can someone help me? My class has just been verified and i haven't even started on the program for Penny's Decking and it's to be done in the next couple of weeks... We're doing it in Python, but i have no idea what to do because i'm terrible at programming and the teacher won't help me. :frown:


Unfortunately I do not know python. If your teacher refuses to help you, then get him/her fired for not doing her job.
Reply 42
hey guys, i really need help. i am the only person doing this coursework from standard grade so i haven't got enough support. i have read what you all wrote but do not understand it. i am doing it on visual basics if there is anyone who could help me understand the programming that would be much appreciated. thank you.
Reply 43
Original post by toffie
hey guys, i really need help. i am the only person doing this coursework from standard grade so i haven't got enough support. i have read what you all wrote but do not understand it. i am doing it on visual basics if there is anyone who could help me understand the programming that would be much appreciated. thank you.


How much of VB do you know?
Reply 44
Original post by Async
How much of VB do you know?

the basics, like how to make a simple programme. i was going to use a drop box menu on the forum but i don't know the code for it.
Reply 45
Original post by toffie
the basics, like how to make a simple programme. i was going to use a drop box menu on the forum but i don't know the code for it.


I would help you but I'm very busy atm.
guys I have a question ..how would u deal with unexpected input? already set up the variable as Integer (it needs to be an integer) but the input is e.g. a letter or question mark? how would you code it so the program doesn't crash every time the user types in something else than simple 1,2,3etc.? (using VB)
(edited 9 years ago)
Reply 47
Original post by Maggie9089
guys I have a question ..how would u deal with unexpected input? already set up the variable as Integer (it needs to be an integer) but the input is e.g. a letter or question mark? how would you code it so the program doesn't crash every time the user types in something else than simple 1,2,3etc.? (using VB)


There are multiple ways to deal with unexpected input depending on the specific case. You can use validation or exception handling.

For example, if you are expecting an Integer you can use Integer.TryParse() method to try and "parse" the input. IntegerTryParse() will return true if the input can be converted to an Integer and false if it can't.

However, you can also use a TryCatch statement to catch errors. It is the most common way for handling errors, but it should be used as a last resort if there is no way you can prevent the error in the first place. A try catch statement works by trying a bit of code, and if any errors occur, it will catch and execute a set of codes.

You could use a TryCatch statement in your case, but it is usually better to prevent an error than to catch one. For example, if I were a police man, you would regard me as a better police man if I prevented a criminal from killing someone, than if I waited for the criminal to kill someone then arrested them. It's the same philosophy. A TryCatch statement waits for the error before catching it. So in your case it would be better to validate the input by using Integer.TryParse()

This is the VB.NET example of the Integer.TryParse() example

Spoiler



This is the TryCatch solution

Spoiler




The both work the same way, but if possible, ALWAYS prevent the error from happening in the first place by using validation checks. If there is not viable way of preventing the error, then it would be appropriate to use a try catch statement.

Hope that helps.
(edited 9 years ago)
Original post by Async
There are multiple ways to deal with unexpected input depending on the specific case. You can use validation or exception handling.

For example, if you are expecting an Integer you can use Integer.TryParse() method to try and "parse" the input. IntegerTryParse() will return true if the input can be converted to an Integer and false if it can't.

However, you can also use a TryCatch statement to catch errors. It is the most common way for handling errors, but it should be used as a last resort if there is no way you can prevent the error in the first place. A try catch statement works by trying a bit of code, and if any errors occur, it will catch and execute a set of codes.

You could use a TryCatch statement in your case, but it is usually better to prevent an error than to catch one. For example, if I were a police man, you would regard me as a better police man if I prevented a criminal from killing someone, than if I waited for the criminal to kill someone then arrested them. It's the same philosophy. A TryCatch statement waits for the error before catching it. So in your case it would be better to validate the input by using Integer.TryParse()

This is the VB.NET example of the Integer.TryParse() example

Spoiler



This is the TryCatch solution

Spoiler




The both work the same way, but if possible, ALWAYS prevent the error from happening in the first place by using validation checks. If there is not viable way of preventing the error, then it would be appropriate to use a try catch statement.

Hope that helps.



Thanks a lot for your help :smile:
Reply 49
Would anyone be able to give a quick bit of code for opening & reading in a file, writing to it & closing it? Please

Quick Reply

Latest

Trending

Trending