SlideShare a Scribd company logo
JAVA WEEK1(A)
/*

Week1 : a) Write a Java program that prints all real solutions to the quadratic
equation ax2 + bx + c = 0. Read in a, b, c and use the quadratic formula. If the
discriminant b2 -4ac is negative, display a message stating that there are no real
solutions. */

public class Quadratic
{
  public static void main(String args[])
  {
        double a,b,c,root1,root2;
        a=3.0;
        b=4.0;
        c=2.0;
        if((b*b-4*a*c)==0)
        {
                System.out.println("n ROOTS ARE EQUAL");
                root1=-b/(2*a);
                System.out.println("n root "+root1);
        }
        if((b*b-4*a*c) > 0)
        {
                 root1=-b+Math.sqrt(b*b-4*a*c)/(2*a);
                 root2=-b-Math.sqrt(b*b-4*a*c)/(2*a);
                 System.out.println("nROOTS ARE REAL:n");
                System.out.println("n root1 "+root1+"n root2 "+root2);
        }
        else
                 System.out.println("n Imaginary Roots.");

   }
} // End of Class




                                       Page 1

More Related Content

What's hot (20)

PPT
Unit ii(dsc++)
Durga Devi
 
PPT
Linked lists
GowriKumar Chandramouli
 
PPT
Operations on linked list
Sumathi Kv
 
PPT
computer notes - Data Structures - 33
ecomputernotes
 
PDF
Circular linked list
maamir farooq
 
PPT
Linked list
eShikshak
 
PPTX
Singly & Circular Linked list
Khulna University of Engineering & Tecnology
 
PPTX
Linear data structure concepts
Akila Krishnamoorthy
 
PPTX
Doubly & Circular Linked Lists
Afaq Mansoor Khan
 
PPSX
Data Structure (Double Linked List)
Adam Mukharil Bachtiar
 
PPTX
Doubly Linked List || Operations || Algorithms
Shubham Sharma
 
PPTX
Array implementation and linked list as datat structure
Tushar Aneyrao
 
PPT
Linked list
Trupti Agrawal
 
PPTX
linked list using c
Venkat Reddy
 
PPTX
Linked list
Md. Afif Al Mamun
 
PPTX
Merge sort code in C explained
Mohit Tare
 
PPTX
Linked list
VONI
 
PPT
Singly link list
Rojin Khadka
 
PDF
Lesson 6 recursion
MLG College of Learning, Inc
 
Unit ii(dsc++)
Durga Devi
 
Operations on linked list
Sumathi Kv
 
computer notes - Data Structures - 33
ecomputernotes
 
Circular linked list
maamir farooq
 
Linked list
eShikshak
 
Singly & Circular Linked list
Khulna University of Engineering & Tecnology
 
Linear data structure concepts
Akila Krishnamoorthy
 
Doubly & Circular Linked Lists
Afaq Mansoor Khan
 
Data Structure (Double Linked List)
Adam Mukharil Bachtiar
 
Doubly Linked List || Operations || Algorithms
Shubham Sharma
 
Array implementation and linked list as datat structure
Tushar Aneyrao
 
Linked list
Trupti Agrawal
 
linked list using c
Venkat Reddy
 
Linked list
Md. Afif Al Mamun
 
Merge sort code in C explained
Mohit Tare
 
Linked list
VONI
 
Singly link list
Rojin Khadka
 
Lesson 6 recursion
MLG College of Learning, Inc
 

Viewers also liked (6)

PDF
Java Week9(B) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week4(B) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week8(A) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week6(B) Notepad
Chaitanya Rajkumar Limmala
 
DOCX
Notepad tutorial
info_zybotech
 
Java Week9(B) Notepad
Chaitanya Rajkumar Limmala
 
Java Week4(B) Notepad
Chaitanya Rajkumar Limmala
 
Java Week8(A) Notepad
Chaitanya Rajkumar Limmala
 
Java Week6(B) Notepad
Chaitanya Rajkumar Limmala
 
Notepad tutorial
info_zybotech
 
Ad

Similar to Java Week1(A) Notepad (18)

PPT
Java Inheritance
Kapish Joshi
 
PPTX
Data Structures and Agorithm: DS 14 Binary Expression Tree.pptx
RashidFaridChishti
 
PPT
Ezmath
Nattawut Phetmak
 
PDF
Basic program in java
Sudeep Singh
 
PPTX
Computer lab (programs)
mshoaib15
 
PDF
Polynomial
Emmanuel Fuchs
 
PDF
Write a Java program that calculates the distance between two points.pdf
poblettesedanoree498
 
DOCX
Java Program
Sudeep Singh
 
PPT
Postfix Evaluations using Stack
Soumen Santra
 
PDF
Class 6 2ciclo
Carlos Alcivar
 
PDF
Java programs
TAUQEER ABBAS
 
PDF
palindrome number armstrong number fibonaccii
ak7209566972
 
PDF
Java Unit 1 Project
Matthew Abela Medici
 
PDF
Lecture 4: Data Types
Eelco Visser
 
PDF
famous placement papers
Ramanujam Ramu
 
ZIP
とある断片の超動的言語
Kiyotaka Oku
 
Java Inheritance
Kapish Joshi
 
Data Structures and Agorithm: DS 14 Binary Expression Tree.pptx
RashidFaridChishti
 
Basic program in java
Sudeep Singh
 
Computer lab (programs)
mshoaib15
 
Polynomial
Emmanuel Fuchs
 
Write a Java program that calculates the distance between two points.pdf
poblettesedanoree498
 
Java Program
Sudeep Singh
 
Postfix Evaluations using Stack
Soumen Santra
 
Class 6 2ciclo
Carlos Alcivar
 
Java programs
TAUQEER ABBAS
 
palindrome number armstrong number fibonaccii
ak7209566972
 
Java Unit 1 Project
Matthew Abela Medici
 
Lecture 4: Data Types
Eelco Visser
 
famous placement papers
Ramanujam Ramu
 
とある断片の超動的言語
Kiyotaka Oku
 
Ad

More from Chaitanya Rajkumar Limmala (11)

PDF
Java Week3(A) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week10 Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week9(A) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week7 Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week6(A) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week4(A) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week4(C) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week1(B) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week2(C) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week2(B) Notepad
Chaitanya Rajkumar Limmala
 
PDF
Java Week2(A) Notepad
Chaitanya Rajkumar Limmala
 
Java Week3(A) Notepad
Chaitanya Rajkumar Limmala
 
Java Week10 Notepad
Chaitanya Rajkumar Limmala
 
Java Week9(A) Notepad
Chaitanya Rajkumar Limmala
 
Java Week7 Notepad
Chaitanya Rajkumar Limmala
 
Java Week6(A) Notepad
Chaitanya Rajkumar Limmala
 
Java Week4(A) Notepad
Chaitanya Rajkumar Limmala
 
Java Week4(C) Notepad
Chaitanya Rajkumar Limmala
 
Java Week1(B) Notepad
Chaitanya Rajkumar Limmala
 
Java Week2(C) Notepad
Chaitanya Rajkumar Limmala
 
Java Week2(B) Notepad
Chaitanya Rajkumar Limmala
 
Java Week2(A) Notepad
Chaitanya Rajkumar Limmala
 

Recently uploaded (20)

PPTX
Peer Teaching Observations During School Internship
AjayaMohanty7
 
PPTX
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
PDF
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
PDF
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
PPTX
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
 
PPTX
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
 
PPTX
How to use _name_search() method in Odoo 18
Celine George
 
PPTX
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
 
PPTX
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
PDF
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
PDF
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
 
PPTX
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
PPTX
Urban Hierarchy and Service Provisions.pptx
Islamic University of Bangladesh
 
PDF
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
PPTX
How to Add New Item in CogMenu in Odoo 18
Celine George
 
PPTX
Photo chemistry Power Point Presentation
mprpgcwa2024
 
PPTX
How Physics Enhances Our Quality of Life.pptx
AngeliqueTolentinoDe
 
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
DOCX
ANNOTATION on objective 10 on pmes 2022-2025
joviejanesegundo1
 
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
Peer Teaching Observations During School Internship
AjayaMohanty7
 
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
 
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
 
How to use _name_search() method in Odoo 18
Celine George
 
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
 
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
 
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
Urban Hierarchy and Service Provisions.pptx
Islamic University of Bangladesh
 
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
How to Add New Item in CogMenu in Odoo 18
Celine George
 
Photo chemistry Power Point Presentation
mprpgcwa2024
 
How Physics Enhances Our Quality of Life.pptx
AngeliqueTolentinoDe
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
ANNOTATION on objective 10 on pmes 2022-2025
joviejanesegundo1
 
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 

Java Week1(A) Notepad

  • 1. JAVA WEEK1(A) /* Week1 : a) Write a Java program that prints all real solutions to the quadratic equation ax2 + bx + c = 0. Read in a, b, c and use the quadratic formula. If the discriminant b2 -4ac is negative, display a message stating that there are no real solutions. */ public class Quadratic { public static void main(String args[]) { double a,b,c,root1,root2; a=3.0; b=4.0; c=2.0; if((b*b-4*a*c)==0) { System.out.println("n ROOTS ARE EQUAL"); root1=-b/(2*a); System.out.println("n root "+root1); } if((b*b-4*a*c) > 0) { root1=-b+Math.sqrt(b*b-4*a*c)/(2*a); root2=-b-Math.sqrt(b*b-4*a*c)/(2*a); System.out.println("nROOTS ARE REAL:n"); System.out.println("n root1 "+root1+"n root2 "+root2); } else System.out.println("n Imaginary Roots."); } } // End of Class Page 1