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

Results Non Return

The document outlines 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, percentage, and 'Pass'; otherwise, it shows 'Fail'. The program uses a Scanner for input and performs calculations to determine the total marks and percentage before invoking the Results() function.

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)
4 views1 page

Results Non Return

The document outlines 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, percentage, and 'Pass'; otherwise, it shows 'Fail'. The program uses a Scanner for input and performs calculations to determine the total marks and percentage before invoking the Results() function.

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 Non – return type.

//Program to display results as Non Return Type


import java.io.*;
import java.util.Scanner;
class ResultsNonRet {
public static void Results(String nm,float per) {
if(per > 60)
System.out.print(nm+" with Percentage "+per+" has Passed");
else
System.out.print(nm+" with Percentage "+per+" has Failed");
}
//Main function begins
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
//Declaring of variables
String nm;float per=0,m,totm=0,per1=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;
}
per1=(totm/600)*100;
Results(nm,per1);
}
}

You might also like