Computer Science, asked by rashi701729, 1 year ago

write a java Program
to accept name, roll number and marks in three subjects for a student Calculate total
marks and percentage. Print name, roll number percentage Alo print pass or fail
(if passmarks is taken as 40).​

Answers

Answered by anshika223
4

a java Program

to accept name, roll number and marks in three subjects for a student Calculate total

marks and percentage. Print name, roll number percentage Alo print pass or fail

(if passmarks is taken as 40).

Answered by poojan
18

Java program to calculate total, percentage and status.

Language used: Java Programming

Program:

import java.util.*;

public class Main

{

public static void main(String[] args) {

 Scanner sc = new Scanner(System.in);

 String name = sc.nextLine();

 String roll_no = sc.nextLine();

 float total=0;

 for(int i=0; i<3; i++)

 {

     int x=sc.nextInt();

     total=total+x;  //Let us think each subject marks total=30

 }

 System.out.println("Total marks is "+total);

 float p=(total/90)*100;

 System.out.println("Percentage is "+ p+("%"));

 //To pass, total should be 40 or more.

 if(total>=40)

 {

     System.out.println("Pass");

 }

 else{

     System.out.println("Fail");

 }

}

}

Input 1:

Arjun

17ME1A0522

29

27

24

Output 1:

Total marks is 80.0

Percentage is 88.88889%

Pass

Input 2:

Patralekha

17NE1A0256

15

12

09

Output 2:

Total marks is 36.0

Percentage is 40.0%

Fail

Learn more:

1. Write a program in Java to generate the following pattern using nested loops.

https://brainly.in/question/18819254

2. Write a java program to input name and mobile numbers of all employees of any office. Using "Linear Search", search array of phone numbers for a given "mobile number" and print name of employee if found, otherwise print a suitable message.

https://brainly.in/question/18217872

Similar questions