0% found this document useful (0 votes)
5 views5 pages

Unit VI Programs..

The document contains a series of Java programming exercises for students at Pawar Public School, Pune, focusing on various mathematical computations such as calculating expressions, Pythagorean triplets, square and cube roots, sphere radius from volume, trigonometric expressions, and the discriminant of quadratic equations. Each exercise includes a brief description and the corresponding Java code to implement the solution. The exercises aim to enhance students' understanding of programming and mathematical concepts.

Uploaded by

sachianandladdha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Unit VI Programs..

The document contains a series of Java programming exercises for students at Pawar Public School, Pune, focusing on various mathematical computations such as calculating expressions, Pythagorean triplets, square and cube roots, sphere radius from volume, trigonometric expressions, and the discriminant of quadratic equations. Each exercise includes a brief description and the corresponding Java code to implement the solution. The exercises aim to enhance students' understanding of programming and mathematical concepts.

Uploaded by

sachianandladdha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Pawar Public School, Pune

Std: IX Subject: Computer Applications

1. Write a program to calculate the value of the given expression:


+ +
Take the values of a,b,c as input from the console. Finally, display the result of the
expression to the nearest whole number.

import [Link].*;
public class Example
{
public static void main(String args[])
{
Scanner sc = new Scanner ([Link]) ;
[Link](“Enter value of a, b, c) ;
int a= [Link]() ;
int b= [Link]() ;
int c= [Link]() ;

int d= [Link]((1.0/[Link](a,2))+ (2.0/[Link](b,2)) + (3.0/[Link](c,2))) ;


[Link](“Result is”+d) ;
}
}
2. For every natural number m>1; 2m, m2 -1 and m2+1 form a Pythagorean triplet. Write
a program to input the value of ‘m’ and to display a ‘Pythagorean Triplet’.
import [Link].*;
public class Example
{
public static void main(String args[])
{
Scanner sc = new Scanner ([Link]) ;
[Link](“Enter value of m”) ;
int m = [Link]() ;

[Link](“Pythagorean Triplet is”) ;


[Link]((2*m) + “, “ + ((m*m) +1) + “, “ + ((m*m) -1)) ;
}
}

3. Write a program to input a number. Calculate its square root and cube root. Finally,
display the result by rounding it off.
import [Link].*;
public class Example
{
public static void main(String args[])
{
Scanner sc = new Scanner ([Link]) ;
[Link](“Enter a number”) ;
float x = [Link]() ;
double s = [Link](x);
int rs = [Link](s) ;
double c = [Link](x)
int rc = [Link](c) ;
[Link](“Square Root of “+ x + “= ” + s) ;
[Link](“ Rounded form of Square Root “ + “= ” +rs) ;

[Link](“Cube Root of “+ x + “= ” + c) ;
[Link](“ Rounded form of Cube Root “ + “= ” +rc) ;
}
}
4. The volume of a sphere is calculated by using formula:
volume = * *r3
Write a program to calculate the radius of a sphere by taking its volume as an input:

Hint: radius = √

import [Link].*;
public class Example
{
public static void main(String args[])
{
Scanner sc = new Scanner ([Link]) ;
[Link](“Enter the volume”) ;
double v= [Link]() ;
double r = [Link](v*(3.0/4) *(7.0/22)) ;
[Link](“Radius of sphere is “+ r) ;
}
}
5. A trignometrical expression is given as:

Write a program to calculate the value of the given expression by taking the values of
angles A and B (in degrees ) as input.
Hint: radian = * degree

import [Link].*;
public class Example
{
public static void main(String args[])
{
Scanner sc = new Scanner ([Link]) ;
[Link](“Enter value of A and B in degrees”) ;
double Da = [Link]() ;
double Db=[Link] () ;
double A = (22.0/(7*180)) *Da;
double B = (22.0/(7*180)) *Db;

double res= ([Link](A) – [Link](B)) /(1+ ([Link](A) *[Link](B)) ) ;

[Link](“Result is”+res) ;
}
}
6. The standard form of a quadratic equation is represented as:
ax2+bx+c=0
where d= b2-4ac , known as ‘Discriminant’ of the equation. Write a program to input
the values of a, b and c. Calculate the value of discriminant and display the output to
the nearest whole number.
import [Link].*;
public class Example
{
public static void main(String args[])
{
Scanner sc = new Scanner ([Link]) ;
[Link](“Enter value of a, b, c”) ;
int a = [Link]() ;
int b = [Link]() ;
int c = [Link]() ;

int d = [Link](b*b – 4*a*c) ;


[Link](“Value of Discriminant is” +d) ;

}
}

You might also like