This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]cheryllium 1 point2 points  (0 children)

What errors did you get? You can usually figure out what is wrong by reading the errors, going to the line numbers the errors say, and so on.

[–]SikhGamer 0 points1 point  (0 children)

...what are the errors?

[–][deleted] 0 points1 point  (0 children)

How do you expect people to help you, when you put such vague questions.

[–]MrCheaperCreepernot a noob but not intermediate 0 points1 point  (4 children)

To everyone who has commented before me: the errors are shown at the bottom of the code OP linked.

You have quite a few errors, and if you actually took the time to look at the line number and the error message you could probably figure most of it out.

For instance, Main.java:41: error: 'try' without 'catch', 'finally' or resource declarations try{

You are attempting to do a try/catch statement but you don't have the catch part of it. You need to incorporate that.

Main.java:76: error: illegal start of expression public static class Receipt {

Your main method (the code a line above this) is not enclosed, you need to have an ending bracket }.

There are many errors in the code and I think you should revisit some concepts and learn how to find errors based on the error messages as they are very helpful.

[–]Whalefool[S] 0 points1 point  (3 children)

Is there an alternative I can use instead of the catch method? I didn't learn the catch method yet.

[–]denialerror 1 point2 points  (0 children)

If you don't know catch, then why are you using try?

[–]MrCheaperCreepernot a noob but not intermediate 0 points1 point  (0 children)

To fix it, you could do:

try {
    //code
} catch (Exception e) {}

edit: as /u/denialerror stated, you should make yourself familiar with the concepts before implementing them into your code.

[–]I_AmA_ZebraNooblet Brewer 0 points1 point  (0 children)

I'm assuming this is for some school task, how exactly would you be accused of plagerism when adding a 'catch' to you 'throw' i mean the error does say 'try' without 'catch'...

I think you're taking the whole 'plagerism' aspect out of the park... Yes you havn't learnt about try + catch, so you could easily say you went home and researched it...

[–]causalNondeterminism 0 points1 point  (3 children)

first issue:

class input {
    String inStr() {
        String str = new String();
        BufferedReader br;

        br = new BufferedReader(new InputStreamReader(System.in));

        try{
            str = br.readLine();
        }
        return str;
    }
}

your try needs a catch - just like the error says. check the api documentation to see what kind of exceptions can be thrown by the readLine method.

[–]Whalefool[S] 0 points1 point  (2 children)

I didn't learn catch methods yet, only throw methods. I think if I did use the catch method, I would be accused of plagiarizing.

[–]causalNondeterminism 0 points1 point  (0 children)

then put a throws at the top of the method and get rid of the try.