Java program type casting

March 29, 2022 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp
PROGRAM:


import java.util.Scanner;


public class IfElse {
public static void main(String args[])
{
int marksObtained, passingMarks;
passingMarks =40;
Scanner input = new Scanner(System.in);
System.out.println(“Input marks scored by you”);

marksObtained = input.nextInt();

if(marksObtained >= passingMarks)
{
            System.out.println(“You passed the exam”);
}
else
{
            System.out.println(“Unfortunately you failed to pass the exam”);
}
}
}


OUTPUT:

Input marks scored by you
50
You passed the exam


Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion