Chapter 1- Java Programming Exercise 1: CBSE Board Percentage Calculator




Exercise 1.1

Write a program to calculate the percentage of a given student in the CBSE board exam. His marks from 5 subjects must be taken as input from the keyboard. (Marks are out of 100)

package com.company;
import java.util.Scanner;
public class CWH_05_TakingInpu {
public static void main(String[] args) {
System.out.println("Calculating Percentage Marks of Student");
Scanner sc=new Scanner(System.in);
System.out.println("Enter Marks of Math");
float a= sc.nextFloat();
System.out.println("Enter Marks in English");
float b=sc.nextFloat();
System.out.println("Enter Marks in Biology");
float c=sc.nextFloat();
System.out.println("Enter Marks in Physics");
float d=sc.nextFloat();
System.out.println("Enter Marks in Chemistry");
float e=sc.nextFloat();

float sum=a+b+c+d+e;
float percentage=(sum/500)*100;
System.out.println("Percentage of Marks :");
System.out.print(percentage);
System.out.print("%");

}

}


Solution :
Output :
Calculating Percentage Marks of Student
Enter Marks of Math
52
Enter Marks in English
60
Enter Marks in Biology
48
Enter Marks in Physics
90
Enter Marks in Chemistry
82
Percentage of Marks :
66.399994%
Aryadeep

Welcome to CodeWithARYA. It's My Personal Reference Website. Where You Can Get Amazing Codes. Have a Look.

Post a Comment

Previous Post Next Post