Hyderabad Local Train Timings   Andhra Tourist Spots   Telangana Issue - SriKrishna Committee   APPSC Exams Online Guide   
AndhraSpider.com
 
 


ForumResourcesTolly UpdatesEntrance ExamsQuestion Bank



My Profile


Active Members
Today
    Last 7 Daysmore...



    Resources » Education » Andhra Pradesh school/colleges/university news


    JNTU Hyderabad CSE/IT Java OOPS Week 1A - Finding the roots of a quadratic equation


    Posted Date:     Category: Andhra Pradesh school/colleges/university news    Rating: 2 out of 52 out of 5
    Author: Member Level: Gold    Points: 5 (Rs 2)


    Are you looking for JNTU Hyderabad CSE/IT solved java 2-2 lab assignments and week programs ? Here is the perfect resource for you . You can directly copy and paste the below code in a Java Editor to excecute the program.


    Get the solutions for JNTU Btech Lab java programs for CSE and Information Technology branches . The resource includes the clear explanation of the code. The below code was uploaded only after the successful execution using Java Standard Edition. JNTU Hyderabad and affiliated colleges conducts a lab session every week for all B.tech Regular students. Here I'm giving solution for the Week 1 1st program. The aim of the program is to find the roots of quadratic equation using a simple java program .You can also get more information about JNTU Java programs solutions on this site for all weeks.
    Input: The user gives the coefficients of quadratic equation as input.
    The programs reads three values a,b,c to solve the roots of equation.
    We know the roots of equation are
    r1=-b+sqrt(b2-4*a*c)/2*a
    r2=-b-sqrt(b2-4*a*c)/2*a
    This can be solved in java by implementing the following source code. With this, you have successfully completed the week 1 first program of your Jntu CSE/IT 2-2 Syllabus.

    //To find roots of a quadratic equation using java
    class Root //Define a class
    {
    public static void main(String[] args)
    {
    int d=0;/Initialise discriminant
    double r1=0,r2=0;//r1,r2 are the roots
    int a=Integer.parseInt(args[0]);//Take the first argument as 'a'
    int b=Integer.parseInt(args[1]);//take the second argument as 'b'
    int c=Integer.parseInt(args[2]);//take the third argument as 'c'
    d=((b*b)-(4*a*c));//calculate discriminant
    if(d==0)//if the roots are equal
    {
    System.out.println("roots are real and equal");
    r1=(-b)/(2*a);//root 1
    r2=(-b)/(2*a);//root 2
    System.out.println(r1);//display root 1
    System.out.println(r2);//display root 2
    }
    else if(d>0)//if roots are not equal
    {
    System.out.println("roots are real and distinct");//display that roots are not equal
    r1=(-b+Math.sqrt(d))/(2*a);//calculate root 1
    r2=(-b-Math.sqrt(d))/(2*a);//calculate root 2
    System.out.println(r1);//display root 1
    System.out.println(r2);//display root 2
    }
    else//if roots are imaginary
    {
    System.out.println("no real solutions");//diaplay there is no solution
    }
    The output will be as follows:

    Output
    D:\education\java\programs>javac Root.java
    D:\education\java\programs>java Root 1 -4 4
    roots are real and equal
    2.0
    2.0


    Did you like this resource? Share it with your friends and show your love!




    Related Resources:


    Read related articles: JNTU lab assignments    JNTU Hyderabad    


    Responses to "JNTU Hyderabad CSE/IT Java OOPS Week 1A - Finding the roots of a quadratic equation"

    No responses found. Be the first to respond...

    Feedbacks      

    Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: LIST OF NIT(National Institute of Technology) Institute, Which has More Seats.
    Previous Resource: JNTU Hyderabad CSE/IT Java OOPS Week 1B - To find the numbers of Fibonacci series
    Return to Resources
    Post New Resource
    Category: Andhra Pradesh school/colleges/university news


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Jntu Hyderabad  .  Week programs  .  Java programs  .  Lab programs  .  Jntu week programs  .  

    Subscribe to Email
  • Get Jobs by Email
  • Forum posts by Email
  • Articles by Email

  • Skilled Writer?

    Part time content writers wanted for several websites to work online from home.
    Skills: Excellent English writing skills. Good English skills with basic computing knowledge needed. Visit the link below for more details

    Online Content Writing Jobs

    Online membersMore...


    Areas
  • Adilabad
  • Anantapur
  • Chittoor
  • Cuddapah
  • East Godavari
  • Guntur
  • Hyderabad
  • Karim Nagar
  • Khammam
  • Krishna
  • Kurnool
  • Mahabub Nagar
  • Medak
  • Nalgonda
  • Nellore
  • Nizamabad
  • Prakasam
  • Ranga Reddy
  • Rangareddy
  • Srikakulam
  • Visakhapatnam
  • Vizianagaram
  • Warangal
  • West Godavari

  • Awards & Gifts



    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2011 All Rights Reserved.