java - GCD, Euclid's Algorithm -


i can't seem find solution error.. please dont judge me. beginner here.

import java.util.scanner; public class greatestcommondivisor {      public static void main(string[] args) {         scanner kbd = new scanner(system.in);         int num1;         int num2;         int gcd;         boolean again = false;          {             system.out.print("first positive integer: ");             num1 = inputposint();          system.out.print("second positive integer: ");                       num2 = inputposint();             //....             gcd = gcd();             (again) = tryagain();         } while (again);    {                 system.out.println("thank testing program.");         }      }     public static int inputposint () {         scanner kbd = new scanner(system.in);          int num;          num = kbd.nextint();          if (num < 0) {             system.out.println("entered integer value non-positive.");             return 0;         }          return num;      }      public static int gcd(int num1, int num2) {        if (num2==0) {         return num1;              }      return gcd(num2,num1%num2); }       public static boolean tryagain() {         scanner kbd = new scanner(system.in);         system.out.print("would try again? [y/n]");         char again;         again = kbd.nextline().charat(0);         if (again == 'y' || again == 'y') {             return true;         }          else if (again == 'n' || again == 'n') {             system.exit(0);         }          return false;     }  } 

this program requires 2 positive integer inputs, , solves gcd, using euclid's algorithm.

error: gcd = gcd(); ^ required: int,int found: no arguments reason: actual , formal argument lists differ in length 1 error

when calling gcd function, need pass in 2 integers arguments. in case 2 integers 2 read in. so, should like:

gcd = gcd(num1, num2); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -