0% found this document useful (0 votes)
3 views1 page

Results Return

The document contains a Java program that defines a user-defined function called Results() to calculate a student's percentage based on marks from six subjects. If the percentage is above 60%, it displays the student's name along with the percentage and 'Pass'; otherwise, it shows 'Fail'. The program utilizes a Scanner for input and performs calculations to determine the result.

Uploaded by

abhishekminz789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Results Return

The document contains a Java program that defines a user-defined function called Results() to calculate a student's percentage based on marks from six subjects. If the percentage is above 60%, it displays the student's name along with the percentage and 'Pass'; otherwise, it shows 'Fail'. The program utilizes a Scanner for input and performs calculations to determine the result.

Uploaded by

abhishekminz789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Q.

Write a User defined function program called Results( ), which shall ask you to enter a student’s name
and marks of any Six subjects. Calculate the percentage marks, if percentage is above 60%, then display
the Student’s name, percentage marks and “Pass” otherwise display the Student’s name, percentage
marks and “Fail”, as return type.

//Program to display results as Return Type


import java.io.*;
import java.util.Scanner;
class ResultsReturn {
public static float Results(float totm) {
float per=(totm/600)*100;
return per;
}
//Main function begins
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
//Declaring of variables
String nm;float m,totm=0,d=0;
System.out.print("Enter name ");
nm=sc.next();
for(int i=1;i<=6;i++) {
System.out.print("Enter marks ");
m=sc.nextFloat();
totm=totm+m;
}
d=Results(totm);
if(d > 60)
System.out.print(nm+" with Percentage "+d+" has Passed");
else
System.out.print(nm+" with Percentage "+d+" has Failed");
}
}

You might also like