/* Question :-
A class contains 'b' number of boys and 'g' number of girls. On a rainy day, 'ba' number of boys and 'ga' number of girls are absent. Write a program to input the values of 'b', 'g', 'ba' and 'ga'. Calculate and display the following:
(i) Percentage of girls present in the class.
(ii) Percentage of boys present in the class.
[Percentage must be calculated on the total number of Students]
*/
import java.io.*;
class Class
{
public static void main(String args[])throws IOException
{
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
int b,g,ba,ga;
float per_boys,per_girls;
System.out.println("Enter the number of boys and girls in the class");
b=Integer.parseInt(in.readLine());
g=Integer.parseInt(in.readLine());
System.out.println("Enter the number of boys and girls in the class who were absent");
ba=Integer.parseInt(in.readLine());
ga=Integer.parseInt(in.readLine());
per_girls=(float)(g-ga)/(g+b)*100;
per_boys=(float)(b-ba)/(g+b)*100;
System.out.println("The Percentage of girls Present in the class : "+per_girls+"%");
System.out.println("The Percentage of boys Present in the class : "+per_boys+"%");
}
}
No comments:
Post a Comment