java - Frustrating Syntax Issues with passing values into methods -


i needed rewrite java program had completed include class able test using junit4. unfortunately can't point because i'm receiving error. it's simple program ask user 3 numbers, pass values function calculations , should return print statement value back. made work without function , i'm having trouble syntax , understanding can , can't methods.

here is:

import java.util.scanner;  public class main {      public static void main(string[] args) {         scanner kybd = new scanner(system.in);          system.out.println("given ax^2 + bx^2 + c = 0");         system.out.println("please enter 'a', 'b', , 'c' determine if there roots: ");         float numa = kybd.nextfloat();         float numb = kybd.nextfloat();         float numc = kybd.nextfloat();          quadraticanswer(numa, numb, numc);      }      public static void float quadraticanswer (float numa, float numb, float numc){         float discriminant = ((numb*numb)-(4*numa*numc));          if (discriminant < 0){             system.out.println("the equation has no roots!");         }          else if (discriminant ==0) {             float root = (-numb + math.sqrt(discriminant))/(2*numa);             system.out.println("the equation has 1 root: "+ root);         }          else {             float root1 = (-numb + math.sqrt(discriminant))/(2*numa);             float root2 = (-numb - math.sqrt(discriminant))/(2*numa);             system.out.println("the equation has 2 roots: " + root1 + " , " + root2 + ".");         }     }     } 

change invalid syntax of

public static void float quadraticanswer  

to

public static void quadraticanswer  

as not returning anything.

if use ide eclipse highlight such errors


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -