Java coding question.

12. If the marks obtained by student in five subject are input through the keyboard ,write a program to find out the aggregate marks and percentage marks obtained by a student in each subject is 100.

package com.company;

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
// write your code here
Scanner sc = new Scanner(System.in);
int operating_System, DSA, DBMS , java , IOT,total;
float percentage;


System.out.println("Enter your marks ");
System.out.print("operating system : " );
operating_System = sc.nextInt();
System.out.print("DSA : ");
DSA= sc.nextInt();
System.out.print("DBMS : ");
DBMS=sc.nextInt();
System.out.print("Java : ");
java= sc.nextInt();
System.out.print("IOT : ");
IOT= sc.nextInt();
total=operating_System+DSA+DBMS+java+IOT;

System.out.println("Total marks obtained out of 500 : "+total);
float c = total; //here i do typecasting which convert int to float
percentage=(float)((c)/500)*100;
System.out.println("Percentage Scored : "+percentage);

}
}

output:-
Enter your marks 
operating system : 90
DSA  : 90
DBMS : 90
Java : 90
IOT : 90
Total marks obtained out of 500 : 450
Percentage Scored : 90.0

Process finished with exit code 0






Comments

Popular posts from this blog

Phone Dictionary Application in c

swapping of two number in java with algorithm.

Dollar to Rupee and Rupee to Dollar app .