JAVA PROGRAMMING! PLEASE TELL THE ANSWERS! I WILL MARK AS BRAINLIEST ! EVEN IF YOU KNOW ONE ANSWER PLEASE TELL!
Answers
Answer:
// program no 1//
public class Main
{
public static void main(String[] args) {
int sum=1;
int p=2;
for(int i=0;i<10;i++)
{
System.out.print(sum+",");
sum=sum+p;
p=p+2;
}
}
}
// program 2 //
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
if(a>b && a>c)
{
System.out.println("greater is "+a);
}
if(b>a && b>c)
{
System.out.println("greater is "+b);
}
if(c>b && c>a)
{
System.out.println("greater is "+c);
}
}
}
// program 3 //
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
int sum=0;
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int d=sc.nextInt();
sum=(sum*10)+a;
sum=(sum*10)+b;
sum=(sum*10)+c;
sum=(sum*10)+d;
System.out.println(sum);
}
}
// program 4 //
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
int sum=0;
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int d=sc.nextInt();
sum=(sum*10)+d;
sum=(sum*10)+c;
sum=(sum*10)+b;
sum=(sum*10)+a;
System.out.println(sum);
}
}
// program 5 //
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
int a=sc.nextInt();
int sum=0;
while(a>0)
{
int r=a%10;
a=a/10;
sum=(sum*10)+r;
}
while(sum>0)
{
int z=sum%10;
sum=sum/10;
System.out.println(z);
}
}
}
Explanation:
i wrote all 5 programs.