Sat. Sep 26th, 2020

Program to Find Arithmetic Series in java Programming by taking user

import java.util.Scanner;
 class ArithmeticSeries 
 {
     public static void main(String args[])
 {
 int n=6;  //limit
int d=3;   //common diffrence
 int a=2;   //terms

Scanner sc=new Scanner(System.in);

 System.out.print("Enter first no of a:");

 a=sc.nextInt();

 System.out.print("Enter the difference of d:"); 
d=sc.nextInt();
 System.out.print("Enter the Limit value of n:"); n=sc.nextInt();

 for(int i=1;i<=n;i++)
{ 
    System.out.print(""+a); 
    a=a+d;   //adding diffrence with term
  }
 }
 }

/*OUTPUT
Enter first no of a:9
 Enter the difference of d:2
 Enter the Limit value of n:3
 9 11 13
 Process completed.*/

READ MORE

Leave a Reply

Your email address will not be published. Required fields are marked *