Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

two constructor two class and four methods.

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Posts: 70354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope Maneesh won't mind me adding the code tags for you because you are new (welcome to the Ranch ); read about the tags here, and always use them because the code looks so much better.

You haven't asked a question. What is the code about? Is it to do with quadratic equations?
You have imported sqrt statically and written Math.sqrt!
Posts: 7734
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Why have you wrote two nearly identical classes (Root1 and Root2) they differ only in 2 lines? You can re-use same class by creating 2 instances of it.
2. Also, you don't need to import java.lang.Math.sqrt as java.lang full package is being imported implicitly by default. Scanner no need to be imported too as you don't use it within Root1 class.
3. For the instance variables you have default (package-private) access modifiers. Better would be to have them private.
Posts: 1248
Hibernate jQuery Eclipse IDE Angular Framework Spring MySQL Database AngularJS Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

  • Program will not compile because in RootMain class you wrote print statements in class which is supposed to be in a block Or a method only. You need to move code which takes input from user to main method of RootMain class.
  • You need to import Scanner in RootMain as you are using It for user inputs.
  • When invoking a method method name always followed by parentheses () here in main method

  • Root?

    No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
      Bookmark Topic Watch Topic
    • New Topic