[Question 7] ICSE 2016 Computer Application Solved - Sum Series
Question 7.
Design a class to overload a function SumSeries() as follows:
(i) void SumSeries(int n, double x) - with one integer argument and one double
argument to find and display the sum of the series given below:
s = x/1 - x/2 + x/3 - x/4 + x/5... ... ... to n terms
(ii) void SumSeries() - To find and display the sum of the following series:
s=1 + (1*2) + (1*2*3) + ... ... ... + (1*2*3*4... ... ...*20)
SOURCE CODE
import java.io.*;
import java.util.*;
public class ICSE2016_Ques7_Series
{
double sum;
void SumSeries(int n,double x)
{
for(int i=1;i<=n;i++)
{
if(i%2!=0)
{
sum=sum+(x/i);
}
else if(i%2==0)
{
sum=sum-(x/i);
}
}
System.out.println("OUTPUT for first series ");
System.out.println("Sum when x=6, n=6 : "+sum);
}
void SumSeries()
{
for(int i=1;i<=20;i++)
{
int f=1;
for(int j=1;j<=i;j++)
{
f=f*j;
}
sum=sum+f;
}
System.out.println("OUTPUT for second series ");
System.out.println("Sum = "+sum);
}
}
import java.util.*;
public class ICSE2016_Ques7_Series
{
double sum;
void SumSeries(int n,double x)
{
for(int i=1;i<=n;i++)
{
if(i%2!=0)
{
sum=sum+(x/i);
}
else if(i%2==0)
{
sum=sum-(x/i);
}
}
System.out.println("OUTPUT for first series ");
System.out.println("Sum when x=6, n=6 : "+sum);
}
void SumSeries()
{
for(int i=1;i<=20;i++)
{
int f=1;
for(int j=1;j<=i;j++)
{
f=f*j;
}
sum=sum+f;
}
System.out.println("OUTPUT for second series ");
System.out.println("Sum = "+sum);
}
}
Write a program to accept a number and check whether the number is palindrome
ReplyDeleteor not by using the function name reverse (int n). The function returns the reversed
number to the main program that checks the palindrome number.
Mcritpilifu1998 Jensen Tripp https://marketplace.visualstudio.com/items?itemName=stinalin-pu.Descargar-Brix-VR-gratuita
ReplyDeleteblowgareni
laecoaAcrus-chi1979 Chris Lavin click here
ReplyDeletedownload
https://colab.research.google.com/drive/1U_L8TV9JbP2NV643v5nLk6Pnkjela_gX
click here
wealthrockmencong