In: Computer Science
In Java
1a. Declare a legal identifier for a variable called test as type double.
1b. Create an if.. else statement that will display You get an A if grade is at least 95 else it will display Maybe you get an A next time
Code:
import java.io.*;
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
double test; //Double variable
declaration
Scanner sc = new
Scanner(System.in);
System.out.print("Enter the
mark:");
test=sc.nextDouble(); //user
input
if(test>=95) //condition
{
System.out.println("Grade
A");
}
else
{
System.out.println("Maybe you get
an A next time");
}
}
}
Screenshot of the code:
Screenshot of the output: