Hey there! Sign in to join this conversationNew here? Join for free
    • Wiki Support Team
    • Thread Starter
    Offline

    21
    ReputationRep:
    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.
    Offline

    14
    ReputationRep:
    This is a good idea.
    Offline

    15
    ReputationRep:
    <!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>
    Offline

    15
    ReputationRep:
    My suggestions:
    Minesweeper Master
    Manually reversing strings
    quicksort,
    etc
    • Wiki Support Team
    • Thread Starter
    Offline

    21
    ReputationRep:
    (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.
    • TSR Support Team
    • Welcome Squad
    Offline

    18
    ReputationRep:
    (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
    Offline

    4
    ReputationRep:
    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
    Posted on the TSR App. Download from Apple or Google Play
    • Wiki Support Team
    • Thread Starter
    Offline

    21
    ReputationRep:
    (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
    Offline

    4
    ReputationRep:
    good, will follow that
    Posted on the TSR App. Download from Apple or Google Play
    Offline

    18
    ReputationRep:
    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.
    • Wiki Support Team
    • Thread Starter
    Offline

    21
    ReputationRep:
    (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;
    }


    Offline

    19
    ReputationRep:
    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.
    • Wiki Support Team
    • Thread Starter
    Offline

    21
    ReputationRep:
    (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.
    Offline

    17
    ReputationRep:
    If anyone is stuck here is a partial solution for challenge #1. Happy to help with c# and JavaScript.
 
 
 
  • 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.

  • Poll
    What newspaper do you read/prefer?
    Useful resources
  • 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.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.