Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class IncrementByOne {
- public static void main(String[] args) {
- int n;
- Scanner src=new Scanner(System.in);
- System.out.println("Enter the size of array");
- n=src.nextInt();
- int a[]=new int[n];
- for(int i=0;i<n;i++)
- {
- System.out.println("Enter the element");
- a[i]=src.nextInt();
- }
- System.out.println("The array is ");
- for(int j=0;j<n;j++)
- {
- System.out.println(a[j]);
- }
- System.out.println("What increment factor do you need?");
- int inc=src.nextInt();
- for(int k=0;k<n;k++)
- {
- int temp=a[k]+inc;
- a[k]=temp;
- }
- System.out.println("The new array is with the increment factor "+inc+" is");
- for(int m=0;m<n;m++)
- {
- System.out.println(a[m]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement