Unsolved Java Programs:
) 1. 49 16
1. Write the programs in Java to display the first ten terms of the following series
3 6, 9, 12.
4 & 16, 32
() 2, 5, 10, 17
Using 'for' loop
Answers
import java.io.*;
class fl
{
public static void main (string args[])
{
int s;
try
{
for(int i=1; i<=10 ; i++)
{
s = i * 3; // use the number you want to find the series in place of 3//
system.out.println(s);
}
}
catch (Exception e){}
}
Answer:
First code is to find the first series followed by second.
Explanation:
//For finding the first series.
import java.util.*;
public class third_series_loop{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int a=3,c;
for(int b=1;b<=10;b++){
c=a*b;
System.out.println(a+"*"+b+"="+c);
}
}
}
//Code for finding the second series
import java.util.*;
public class double_number_multiple{
public static void main(String[]args){
Scanner sc=new Scanner (System.in);
int b;
for(int a=4;a<=20;a++){
b=a*a;
System.out.print(b);
System.out.print(",");
}
}
}