SlideShare a Scribd company logo
The sample program for above series in JAVA will be like below
import java.util.Scan;
public class PIVALUE {
public static void main(String[] args) {
// Scan object creation
Scan input = new Scan (System.in);
// ask user for input
System.out.println("Enter num.");
double j = input.nextDouble(); // user entered value of j
double Tot = 0;
for(j=0; j<10000; j++){
if(j%2 == 0) // check remainder of `j/2` is 0
Tot += -1 / ( 2 * j - 1);
else
Tot += 1 / (2 * j - 1);
}
System.out.println(Tot);
}
}
Solution
The sample program for above series in JAVA will be like below
import java.util.Scan;
public class PIVALUE {
public static void main(String[] args) {
// Scan object creation
Scan input = new Scan (System.in);
// ask user for input
System.out.println("Enter num.");
double j = input.nextDouble(); // user entered value of j
double Tot = 0;
for(j=0; j<10000; j++){
if(j%2 == 0) // check remainder of `j/2` is 0
Tot += -1 / ( 2 * j - 1);
else
Tot += 1 / (2 * j - 1);
}
System.out.println(Tot);
}
}

More Related Content

PPTX
Programs.pptx
PPT
Simple Java Programs
PPT
Simple Java Programs
PDF
81818088 isc-class-xii-computer-science-project-java-programs
PPTX
Iteration- series part 1- computer ICSE.pptx
PPTX
Iteration- series ICSE computer part 1.pptx
PDF
Java_Programming_by_Example_6th_Edition.pdf
DOCX
SeriesTester.classpathSeriesTester.project SeriesT.docx
Programs.pptx
Simple Java Programs
Simple Java Programs
81818088 isc-class-xii-computer-science-project-java-programs
Iteration- series part 1- computer ICSE.pptx
Iteration- series ICSE computer part 1.pptx
Java_Programming_by_Example_6th_Edition.pdf
SeriesTester.classpathSeriesTester.project SeriesT.docx

Similar to The sample program for above series in JAVA will be like belowimpo.pdf (20)

DOCX
Programs of java
PDF
Microsoft word java
DOC
Md university cmis 102 week 4 hands on lab new
DOC
Md university cmis 102 week 4 hands on lab new
DOCX
Estructura secuencial -garcia
DOCX
Cis 355 ilab 2 of 6
PDF
Java practical(baca sem v)
PDF
変数の型 - Java 演習
DOC
Md university cmis 102 week 4 hands on lab new
PPT
Java căn bản - Chapter6
DOCX
Problemas secuenciales.
DOCX
Problemas secuenciales.
DOCX
Problemas secuenciales.
DOCX
Problemas secuenciales.
DOCX
Problemas secuenciales.
PPTX
Java Chapter 05 - Conditions & Loops: part 5
PPT
Algorithms with-java-1.0
PPT
Computer Programming, Loops using Java - part 2
PPTX
Presentation1 computer shaan
Programs of java
Microsoft word java
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
Estructura secuencial -garcia
Cis 355 ilab 2 of 6
Java practical(baca sem v)
変数の型 - Java 演習
Md university cmis 102 week 4 hands on lab new
Java căn bản - Chapter6
Problemas secuenciales.
Problemas secuenciales.
Problemas secuenciales.
Problemas secuenciales.
Problemas secuenciales.
Java Chapter 05 - Conditions & Loops: part 5
Algorithms with-java-1.0
Computer Programming, Loops using Java - part 2
Presentation1 computer shaan
Ad

More from rajat630669 (20)

PDF
PriorityQueue.cs Jim Mischel using System; using Sy.pdf
PDF
the balanced equations are H3PO4(aq) + 3[NaOH](.pdf
PDF
Molecular wt. of NaOH = 40 No. of moles of NaOH =.pdf
PDF
images are not visible. post the question again .pdf
PDF
VSEPR is easy if you follow the right steps. 1. .pdf
PDF
This is quite a broad question. I will try to acc.pdf
PDF
}public staatic boolean isValidElement(String token){public vo.pdf
PDF
y=41.2xSolutiony=41.2x.pdf
PDF
What is an example of big data either from your personal experience .pdf
PDF
S-Se=S with 3 lone pairs on the first S, 1 lone.pdf
PDF
The formula for calculating Alveolar ventilation is as followsAlv.pdf
PDF
D. This element can only have a -2 oxidation stat.pdf
PDF
solAn object will allocated statically when that object is needed.pdf
PDF
P = 12SolutionP = 12.pdf
PDF
carbon moves by A. interstitial diffusion So.pdf
PDF
NH4Cl = acid NaOH = base They react 11 Leftover = 0.26-0..pdf
PDF
D is the transition represent!! Solution .pdf
PDF
CO2 is non polar because C has no lone pairs, so .pdf
PDF
As more halide ions are added, it loses its color.pdf
PDF
AppointmentDemo.javaimport java.util.Scanner;    Demonstrat.pdf
PriorityQueue.cs Jim Mischel using System; using Sy.pdf
the balanced equations are H3PO4(aq) + 3[NaOH](.pdf
Molecular wt. of NaOH = 40 No. of moles of NaOH =.pdf
images are not visible. post the question again .pdf
VSEPR is easy if you follow the right steps. 1. .pdf
This is quite a broad question. I will try to acc.pdf
}public staatic boolean isValidElement(String token){public vo.pdf
y=41.2xSolutiony=41.2x.pdf
What is an example of big data either from your personal experience .pdf
S-Se=S with 3 lone pairs on the first S, 1 lone.pdf
The formula for calculating Alveolar ventilation is as followsAlv.pdf
D. This element can only have a -2 oxidation stat.pdf
solAn object will allocated statically when that object is needed.pdf
P = 12SolutionP = 12.pdf
carbon moves by A. interstitial diffusion So.pdf
NH4Cl = acid NaOH = base They react 11 Leftover = 0.26-0..pdf
D is the transition represent!! Solution .pdf
CO2 is non polar because C has no lone pairs, so .pdf
As more halide ions are added, it loses its color.pdf
AppointmentDemo.javaimport java.util.Scanner;    Demonstrat.pdf
Ad

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Pharma ospi slides which help in ospi learning
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Basic Mud Logging Guide for educational purpose
PPTX
GDM (1) (1).pptx small presentation for students
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Cell Structure & Organelles in detailed.
PDF
Complications of Minimal Access Surgery at WLH
Module 4: Burden of Disease Tutorial Slides S2 2025
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pharma ospi slides which help in ospi learning
Microbial disease of the cardiovascular and lymphatic systems
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
RMMM.pdf make it easy to upload and study
102 student loan defaulters named and shamed – Is someone you know on the list?
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Basic Mud Logging Guide for educational purpose
GDM (1) (1).pptx small presentation for students
O5-L3 Freight Transport Ops (International) V1.pdf
Pre independence Education in Inndia.pdf
Final Presentation General Medicine 03-08-2024.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
human mycosis Human fungal infections are called human mycosis..pptx
VCE English Exam - Section C Student Revision Booklet
Cell Structure & Organelles in detailed.
Complications of Minimal Access Surgery at WLH

The sample program for above series in JAVA will be like belowimpo.pdf

  • 1. The sample program for above series in JAVA will be like below import java.util.Scan; public class PIVALUE { public static void main(String[] args) { // Scan object creation Scan input = new Scan (System.in); // ask user for input System.out.println("Enter num."); double j = input.nextDouble(); // user entered value of j double Tot = 0; for(j=0; j<10000; j++){ if(j%2 == 0) // check remainder of `j/2` is 0 Tot += -1 / ( 2 * j - 1); else Tot += 1 / (2 * j - 1); } System.out.println(Tot); } } Solution The sample program for above series in JAVA will be like below import java.util.Scan; public class PIVALUE { public static void main(String[] args) { // Scan object creation Scan input = new Scan (System.in); // ask user for input System.out.println("Enter num."); double j = input.nextDouble(); // user entered value of j double Tot = 0; for(j=0; j<10000; j++){ if(j%2 == 0) // check remainder of `j/2` is 0
  • 2. Tot += -1 / ( 2 * j - 1); else Tot += 1 / (2 * j - 1); } System.out.println(Tot); } }