write a program based on
1. program based on if else.
2. program based on Input through scanner class.
please answer the above given programmings.
kindly don't spam.
Share
write a program based on
1. program based on if else.
2. program based on Input through scanner class.
please answer the above given programmings.
kindly don't spam.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
import java.util.Scanner;
class Conditional
{
public static void main(String[]args)
{
{
System.out.println("Enter your age please.");
}
Scanner sc = new Scanner(System.in);
int age = sc.nextInt();
if(age>=18)
{
System.out.println("Welcome to the voter portal !" );
}
else
{
System.out.println("Sorry, you cannot proceed further. Thank you.");
}
}
}
Explanation:
Hope it's help you:)
Answer:
1.import java.util.Scanner;
class Student{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
if(a>b)
{
System.out.println("a is greater");
}
else
{
System.out.println("b is greater");
}
}
}
2.import java.util.Scanner;
class Student1{
public static void main(
Scanner sc=new Scanner(System.in);
int a=nextInt();
System.out.printf("%d",a);
}
}