Hi
I'm currently learing Java with my book and a teacher at long distance.
I send him my two recent assignments about methods and he told me that they was not correct and gave me some tips and one was to search online so here I em hoping someoen could help me.
The first assignment was to make a method that add together two numbers that the user types in.
here is my code for that one. it is in swedish so some varibels and text might seem strange.
Public class ovning_1{ Public static void main(String[] args){ System.out.print(“mata in det första talet: ”); int tal1 = Keyboard.readint(); System.out.print(”mata in det andra talet: ”); int tal2 = Keyboard.readint(); int summa(int tal1, int tal2); System.out.println(” summan av ” + tal1 + tal2 + ”är ” + summa); } static int summa(int tal1, int tal2) { int summa = (tal1+tal2); Return summa } } The second one is to make a method that reads a number that the user types in and return true if it's 0 or bigger and false if smaller than 0. here is my code for that one. Public class ovning_2{ Public static void main(String[] args){ System.out.print(“Skriv in boooloendet: ”); int tal1 = Keyboard.readint(); system.out.println(”ditt boolon är” + boolean); } Static Boolean(int tal1){ Int boolean; If (tal >=0){ boolean = ture } esle boo = false Retun boo2; } }
I would appreciate any help on these and since it's some in swedish sry for my bad english and try to be simple if your going yo explain complicated things since I'm still learning.
thanks in advance