DayneD89
Badges: 21
Rep:
?
#1
Report Thread starter 3 years ago
#1
I've read a few people on here saying that they are learning to code. I always found the best way to learn programming was through completing projects so I thought I would post a simple project up for people to try.

If people find this useful I'll keep doing them so if you want something harder or easier, a game project or something more theoretical let me know and I'll try to do that next time. Don't be afraid to ask questions, the whole point is to learn.

I use c# academically and usually Java professionally though I have also used Python and C++ (though not in a while). So those are the languages I'll mostly be able to help with. Use whatever language you want to complete the project, but I'll be of most use in Java and if you use an obscure language I won't be able to help as much as I would like to. I recommend Java if you are unsure what language to use.

Challenge #1:

Basic
Design and build a program that will take as input from the user the users yearly income and output the income tax to be paid to the screen. What happens if the user puts in a negative number or a word instead of a number?

Extension 1
Make it so that the user can input weekly, monthly or yearly wage and it gives the tax to be paid. Make sure you account for the user not inputting what you expect!

Extension 2
Make your program implement methods for all the calculations so that your main method only prints to the screen, takes input from the user and calls methods.
3
reply
qasim-96
Badges: 15
Rep:
?
#2
Report 3 years ago
#2
This is a good idea.
0
reply
flatline
Badges: 16
Rep:
?
#3
Report 3 years ago
#3
<!DOCTYPE html> <html> <head> <title>stuff</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> </head> <body> <form> Yearly Income: <input type="Number" id = "Yearly"><br> Monthly Income: <input type="Number" id="Monthly"><br> Weekly Income: <input type="Number" id="Weekly"><br><br> </form> <span id = "Results">Results: </span> <script> $("#Yearly").change(function(){ interest = 0.12; num = $("#Yearly").val(); if (num > 0){ $("#Results").text("Taxes paid: " + parseFloat(num * interest)); } }) $("#Monthly").change(function(){ interest = 0.12; num = $("#Monthly").val() * 12; if (num > 0){ $("#Results").text("Taxes paid: " + parseFloat(num * interest)); } }) $("#Weekly").change(function(){ interest = 0.12; num = $("#Weekly").val() * 52; if (num > 0){ $("#Results").text("Taxes paid: " + parseFloat(num * interest)); } }) </script> </body> </html>
0
reply
flatline
Badges: 16
Rep:
?
#4
Report 3 years ago
#4
My suggestions:
Minesweeper Master
Manually reversing strings
quicksort,
etc
0
reply
DayneD89
Badges: 21
Rep:
?
#5
Report Thread starter 3 years ago
#5
(Original post by flatline)
My suggestions:
Minesweeper Master
Manually reversing strings
quicksort,
etc
Good ideas. I'd like to do something like a top trumps game as well to do arrays, guis and objects if I get a chance but that might be a few projects, build it up bit by bit.
0
reply
RoyalSheepy
Badges: 20
Rep:
?
#6
Report 3 years ago
#6
(Original post by DayneD89)
I've read a few people on here saying that they are learning to code. I always found the best way to learn programming was through completing projects so I thought I would post a simple project up for people to try.

If people find this useful I'll keep doing them so if you want something harder or easier, a game project or something more theoretical let me know and I'll try to do that next time. Don't be afraid to ask questions, the whole point is to learn.

I use c# academically and usually Java professionally though I have also used Python and C++ (though not in a while). So those are the languages I'll mostly be able to help with. Use whatever language you want to complete the project, but I'll be of most use in Java and if you use an obscure language I won't be able to help as much as I would like to. I recommend Java if you are unsure what language to use.

Challenge #1:

Basic
Design and build a program that will take as input from the user the users yearly income and output the income tax to be paid to the screen. What happens if the user puts in a negative number or a word instead of a number?

Extension 1
Make it so that the user can input weekly, monthly or yearly wage and it gives the tax to be paid. Make sure you account for the user not inputting what you expect!

Extension 2
Make your program implement methods for all the calculations so that your main method only prints to the screen, takes input from the user and calls methods.
This is brilliant! I love this idea! :yep:

AngryJellyfish
2
reply
Envisage Me
Badges: 4
Rep:
?
#7
Report 3 years ago
#7
Wicked idea, previously I would have used VBA in excel but I may look to do something in Java/Python as that’s what I’ll be focusing on
0
reply
DayneD89
Badges: 21
Rep:
?
#8
Report Thread starter 3 years ago
#8
(Original post by Envisage Me)
Wicked idea, previously I would have used VBA in excel but I may look to do something in Java/Python as that’s what I’ll be focusing on
If you wanna try in java I can help along the way if you need any help Python I ca probably get familiar with as well if that's what you want to do though. Some of the more fun projects will probably be best done in Java though so I'd go for that
0
reply
JustVladon
Badges: 14
Rep:
?
#9
Report 3 years ago
#9
good, will follow that
0
reply
Dysf(x)al
Badges: 20
Rep:
?
#10
Report 3 years ago
#10
Anyone who wants a challenge, try coding a railfence ciper program that allows you to encode and decode, specifying the number of rails. It's pretty easy with 2 rails, but when you add more, it gets somewhat tricky.
1
reply
DayneD89
Badges: 21
Rep:
?
#11
Report Thread starter 3 years ago
#11
(Original post by TheMindGarage)
Anyone who wants a challenge, try coding a railfence ciper program that allows you to encode and decode, specifying the number of rails. It's pretty easy with 2 rails, but when you add more, it gets somewhat tricky.
That was a fun one, thanks

If anyone's interested in how I did it I have a gui jar file and the encrypt/decrtypt methods I came up with.

Spoiler:
Show


Runnable GUI version

Encrypt Method
public static String encrypt(int rows, String text3) {
String text2 = text3.replaceAll("[.]","";
String text = text2.replaceAll(" ","";
char[][] encrypt = new char[rows][text.length()];

boolean directionUp=false;
int w=0;
for (int i=0;i<text.length();i++) {
encrypt[w][i]=text.charAt(i);
if(directionUp) {
if (w==(rows-1)) {directionUp=false;w-=1;}
else{w+=1;}
} else if (!directionUp) {
if (w==0) {w+=1;directionUp=true;}
else{w-=1;}
}
}

String ans="";
for(int i=0;i<encrypt.length;i++) {
for(int j=0;j<encrypt[0].length;j++) {
if (encrypt[i][j] != 0 ) {ans += encrypt[i][j];}
}
}
return ans;
}


Decrypt Method
private static String decrypt(int rows, String text) {
String[][] decrypt = new String[rows][text.length()];

int count = 0,init = (2*rows)-2,a=init-2,b=2,c;
for (int i = 0; i < decrypt.length; i++) {
c = 0;
for (int u=i;u<decrypt[i].length {
if (count != text.length()) {
if (i == 0 || i == rows-1) {
decrypt[i][u] = "" + text.charAt(count);
u = u+init;
} else {
decrypt[i][u] = "" + text.charAt(count);
if (c%2 == 0) {u+=a;}
else if (c%2 == 1) {u+=b;}
c++;
}
count++;
} else {break;}
}
if (i != 0 && i != rows-1) {
a -=2;
b +=2;
}
}

String ans="";
a=0;
boolean directionUp=true;
for(int i=0;i<decrypt[0].length;i++) {
ans+=decrypt[a][i];
if (directionUp) {
if (a==decrypt.length-1) {a--;directionUp=false;}
else {a++;}
} else if(!directionUp) {
if (a==0) {a++;directionUp=true;}
else {a--;}
}
}
return ans;
}


0
reply
Joinedup
Badges: 20
Rep:
?
#12
Report 3 years ago
#12
Lots of ideas on the codechef website's practice section. https://www.codechef.com/problems/ea...ing_order=desc

read the help pages if you're going to use it to upload and check your code is working properly cos there are some i/o gotchas with the larger test cases.
0
reply
DayneD89
Badges: 21
Rep:
?
#13
Report Thread starter 3 years ago
#13
(Original post by Joinedup)
Lots of ideas on the codechef website's practice section. https://www.codechef.com/problems/ea...ing_order=desc

read the help pages if you're going to use it to upload and check your code is working properly cos there are some i/o gotchas with the larger test cases.
The benefit of doing it on a forum is that you can ask questions of people who are same challenge and may be facing the same problems.
0
reply
INTit
Badges: 17
Rep:
?
#14
Report 3 years ago
#14
If anyone is stuck here is a partial solution for challenge #1. Happy to help with c# and JavaScript.
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

How would you feel if uni students needed to be double vaccinated to start in Autumn?

I'd feel reassured about my own health (28)
15.73%
I'd feel reassured my learning may be less disrupted by isolations/lockdowns (56)
31.46%
I'd feel less anxious about being around large groups (20)
11.24%
I don't mind if others are vaccinated or not (16)
8.99%
I'm concerned it may disadvantage some students (8)
4.49%
I think it's an unfair expectation (47)
26.4%
Something else (tell us in the thread) (3)
1.69%

Watched Threads

View All