🔒 Closed Java if else

Status
Not open for further replies.

SUNRAI

Eternal Poster
Java:
/* Get three exam grades from the user and compute the average of the grades.
Output the average of the three exams. Together with the average,
also include a smiley face in the output if the average is greater than or equal to 60, otherwise output :-(. */

import java.util.Scanner;
public class average {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("Enter the first number: ");
        double num1 = scan.nextDouble();
        System.out.print("Enter the second number: ");
        double num2 = scan.nextDouble();
        System.out.print("Enter the third number: ");
        double num3 = scan.nextDouble();
        scan.close();
        System.out.print("The average of entered numbers is:" + avr(num1, num2, num3));
        if (avr = < 60) {
            System.out.println(":-)");
        } else {
            System.out.println(":-(");

        }
    }

    public static double avr(double a, double b, double c) {
        return (a + b + c) / 3;
    }

}
 
Baliktad condition mo, dapat <= mauna dapat yung < tapos sunod yung =, parang word lang yan pag iimplement. Pag Greater than or equals to (>=), Less than or equals to (<=)
 
Status
Not open for further replies.

About this Thread

  • 3
    Replies
  • 1K
    Views
  • 3
    Participants
Last reply from:
SUNRAI

Online now

Members online
1,062
Guests online
714
Total visitors
1,776

Forum statistics

Threads
2,276,976
Posts
28,973,524
Members
1,229,678
Latest member
wow98
Back
Top