Hyderabad Local Train Timings
Andhra Tourist Spots
Telangana Issue - SriKrishna Committee
APPSC Exams Online Guide
Forum
Resources
Tolly Updates
Entrance Exams
Question Bank
Posting Guidelines
|
Members
|
New Posts
|
behavioral targeting
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Last 7 Days
Biju Cherian
(65)
Sita Kalyani
(11)
S. Sowmya
(7)
more...
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:
22-Jun-2011
Category:
Andhra Pradesh school/colleges/university news
Rating:
Author:
T VENKATA SAI RAM
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.
behavioral targeting
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!
Tweet
Share
behavioral targeting
Related Resources:
JNTU Hyderabad CSE/IT Java OOPS Week 1B - To find the numbers of Fibonacci series
JNTU Hyderabad CSE/IT Java OOPS Week 2A - To find the prime numbers below 'n'
JNTU Hyderabad CSE/IT Java OOPS Week 2B - Multiplication of Two Matrices
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:
behavioral targeting
Notify me by email when others post comments to this article.
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
LIST OF NIT(National Institute of Technology) Institute, Which has More Seats.
JNTU Hyderabad-List of courses
NEET 2011 Notification marked “Invalid” – A controversy
Procedure for obtaining Original Degree Certificate from JNTU
Andhra Pradesh (AP) 10th Class SSC Exams 2011 time table/date sheet announcement
Andhra Pradesh (AP) class 12th Inter 2011 exam time table, date sheet announcement
Popular Tags
Tag posting guidelines
Search Tags
Jntu Hyderabad
.
Week programs
.
Java programs
.
Lab programs
.
Jntu week programs
.
behavioral targeting
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 members
More...
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.