KnowledgeBoat Logo

Computer Applications

Write a program to accept marks in Physics, Chemistry and Biology. The program calculates the average and displays the stream accordingly:

Average MarksStream
80% and aboveComputer Science
60% or more but less than 80%Bio-Science
40% or more but less than 60%Commerce

Java

Java Conditional Stmts

ICSE

58 Likes

Answer

import java.util.Scanner;

public class KboatAvgNStream
{
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter marks in Physics: ");
        int phy = in.nextInt();
        System.out.print("Enter marks in Chemistry: ");
        int chem = in.nextInt();
        System.out.print("Enter marks in Biology: ");
        int bio = in.nextInt();
        double avg = (phy + chem + bio) / 3.0;
        if (avg < 40)
            System.out.println("No stream");
        else if (avg < 60)
            System.out.println("Commerce");
        else if (avg < 80)
            System.out.println("Bio-Science");
        else
            System.out.println("Computer Science");
    }
}

Output

BlueJ output of Write a program to accept marks in Physics, Chemistry and Biology. The program calculates the average and displays the stream accordingly:

Answered By

25 Likes


Related Questions