Input name of a student and two marks. Marks are out of 40 for each subject. Find percentage of total and print it
along with name.
import java.util.*;
public class Result
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println(“Enter name and two marks”);
String na=sc.nextLine();
double m1=sc.nextDouble():
double m2=sc.nextDouble():
double percent=(m1+m2)/80.0*100:
System.out.println(“Name: “+na);
System.out.println(“Percentage: “+percent);
}
}
2.1.
Input name and two marks. Marks are out of 40 for each subject. Find percentage of total.
If percentage is 40 or above print "Admission is granted" along with name.
Otherwise nothing to be done.
import java.util.*;
public class Result
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println(“Enter name and two marks”);
String na=sc.nextLine();
double m1=sc.nextDouble():
double m2=sc.nextDouble():
double percent=(m1+m2)/80.0*100:
if(percent>=40)
{
System.out.println(“Name: "+na);
System.out.println(“Admission is granted.");
}
}
}
2.2.
Input two marks of a student. Marks are in 40 each. Find percentage of total.
If percentage is 40 or above print "Admission is granted".
Otherwise print "No Admission."
import java.util.*;
public class Result
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println(“Enter two marks”);
double m1=sc.nextDouble():
double m2=sc.nextDouble():
double percent=(m1+m2)/80.0*100:
if(percent>=40)
System.out.println(“Admission is granted.");
else
System.out.println(“No Admission.");
}
}
2.3.
Input percentage of marks. Print result.
percentage 80 or above : Distinction. 60 or above : First class.
percentage 50 or above : Second class. 40 or above : Third class.
Others : Failed
import java.util.*;
public class Result
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println(“Enter percentage of marks”);
double per=sc.nextDouble():
if(per>=80)
System.out.println(“Distinction.");
else if(per>=60)
System.out.println(“First class.");
else if(per>=50)
System.out.println(“Second class.");
else if(per>=40)
System.out.println(“Third class.");
else
System.out.println(“Failed.");
}
}
2.4.
Input percentage of marks and syllabus. Print result. ExcellentGoodSatisfactory
ICSE (I)Mark: >=75Mark: >=50 Below 50
CBSE (C) Mark: >=80Mark: >=60 Below 60
Others Wrong choice
import java.util.*;
public class Result
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println(“Enter mark and syllabus [I/C]”);
double m=sc.nextDouble():
char s=sc.next().charAt(0);
if(s=='I'||s=='i')
{
if(m>=75)
System.out.println(“Excellent”);
else if(m>=50)
System.out.println(“Good”);
else
System.out.println(“Satisfactory”);
}
else if(s=='C'||s=='c')
{
if(m>=80)
System.out.println(“Excellent”);
else if(m>=60)
System.out.println(“Good”);
else
System.out.println(“Satisfactory”);
}
else
System.out.println(“Wrong choice”);
}
}
2.5.
Write a menu driven program: 1) Input average, print "Passed" or "Failed". Pass mark is 40 or above.
2) Input percentage, print "Admission granted" or "No admission". Admission percentage is 80 or above.
import java.util.*;
public class Result
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("1 Average: Passed or Failed.");
System.out.println("2 Percentage: Admission or No Admission.");
System.out.println("Enter your choice");
int ch=sc.nextInt();
switch(ch)
{
case 1: System.out.println("Input average of marks: ");
double avg=sc.nextDouble();
if(avg>=40)
System.out.println("Passed");
else
System.out.println("Failed");
break;
case 2: System.out.println("Input percentage of marks: ");
double per=sc.nextDouble();
if(per>=80)
System.out.println("Admission granted");
else
System.out.println("No admission");
break;
default: System.out.println("Wrong input");
}
}
}
3.1.
Input name and percentage of marks of n students. Print "Admission granted" or "No admission" with name.
Admission mark is 80 or above. Also find total number of students who got admission.