You are on page 1of 5

- Write a Java Program that would compute for the area of rectangle.

package appdevfinals;

import java.util.Scanner;

public class AppDevFINALS {

public static void main(String[] args) {

Scanner qwe = new Scanner(System.in);

System.out.print("Enter the LENGTH of rectangle: ");


float l = qwe.nextFloat();

System.out.print("Enter the WIDTH of rectangle: ");


float w = qwe.nextFloat();

float a = l*w;

System.out.println("The AREA of rectangle is " + a);


}
}
- Create a Java Program that would determine an integer if it is POSITIVE or NEGATIVE.

package appdevfinals;

import java.util.Scanner;

public class AppDevFINALS {

public static void main(String[] args) {

Scanner qwe = new Scanner(System.in);

System.out.print("Enter any integer: ");


int num = qwe.nextInt();

if (num >= 0){


System.out.println("Number " + num + " is a POSITIVE number! ");
} else {
System.out.println("Number " + num + " is a NEGATIVE number! ");
}
}
}
- Make a Java Program that would compute for the average of four grading periods. If the average
is equal or greater than 75 display PASSED else FAILED.

package appdevfinals;

import java.util.Scanner;

public class AppDevFINALS {

public static void main(String[] args) {

Scanner qwe = new Scanner(System.in);

System.out.println("Enter your grades from First to Fourth Grading!");


System.out.print("First Grading: ");
float first = qwe.nextFloat();
System.out.print("Second Grading: ");
float second = qwe.nextFloat();
System.out.print("Third Grading: ");
float third = qwe.nextFloat();
System.out.print("Fourth Grading: ");
float fourth = qwe.nextFloat();

float sum = first+second+third+fourth;


float average = sum/4;

System.out.println("\nAverage: " + average);

if (average >= 75){


System.out.println("PASSED");
} else {
System.out.println("FAILED");
}
}
}

You might also like