r/javahelp • • Aug 30 '18

Homework Creating class files

Hey, I'm a first year at uni doing a programming class and I'm having some trouble with some work. I have no idea what to do to be honest, I haven't learnt anything about coding and am just stuck. I understand how class's work as well as attributes and methods, I just don't know how to write the code itself. The work also comes with a prewritten class file and class marks, I don't know what to do with them either. Any help would be appreciated, I have linked below the link to pics of the work.

https://imgur.com/a/HZc7Fqt

0 Upvotes

8 comments sorted by

View all comments

1

u/androgynyjoe Aug 30 '18

I guess I find it hard to believe that you haven't learned anything about coding. This seems like an assignment for Intro to Computer Science or something like that. I'm a bit curious how many days/weeks into the class you are and what you've done so far.

Nevertheless, it seems like you're being asked to create a class and some static methods. These are meant to be like functions; they input something and output something else. I would start by making a file called Marks.java which looks like this:

public class Marks {
    public static int max(int[] someMarks) {
        //some code goes in here to figure out what maxValue should be
        return maxValue;
    }
    public static double mean(int[] someMarks) {
        //some code goes in here to figure out what meanValue should be
        return meanValue;
    }
    //there should be more of these for each of the methods requested
}

For example, the method that I called max should input an array of integers (int[]) which I've called someMarks and return another int which is the maximum value found in someMarks.

Of course, you say you were given a pre-written class "Marks" so maybe this much has already been done for you.

-1

u/[deleted] Aug 30 '18

I just started this subject, and I joined in late. I haven't been able to catch up and I'm having trouble with the work. I don't have a working program to use either.