Computer Science, asked by aaryasancheti20, 10 months ago

In a class of 'n' number of students, the number of girls is 'm'.
Write a program to input the values of n and m. Find and display
the percentage of boys and girls in the class.



plz do not spam
if u write the correct program using InputStreamReader I will follow u and give thanks.​

Answers

Answered by shreyajoby225
17

Answer:

package collection;

import java.util.Scanner;

public class SwapNumber {

public static void main(String[] args) {

 

 Scanner sc= new Scanner(System.in);

 int m,n;

 System.out.println("Enter no. of boys in class");

 m=sc.nextInt();

 System.out.println("Enter no. of girls in class");

 n=sc.nextInt();

 System.out.println("Percentage of boys in class: "+(double)m/(m+n)*100+"%");

 System.out.println("Percentage of girls in class: "+(double)n/(m+n)*100+"%");

}

}

Output:

Enter no. of boys in class

50

Enter no. of girls in class

123

Percentage of boys in class: 28.901735%

Percentage of girls in class: 71.09826589595376%

Answered by gshruthilaya09
3

Answer:

Explanatio n

//To find and display the percentage of boys and girls

import java.io.*;

class number

{

public static void main(String args [ ])throws IOException

{

InputStreamReader read=new InputStreamReader(System.in);

int n,m,b;

double perg,perg ;

System.out.println(" Enter number of student and girls");

n=Integer.parseInt(in.readLine ( ) );

m=Integer.parseInt(in.readLine ( ) );

b=n-m;

perb=(double)b/n*100;

perb=(double)m/n*100;

System.out.println("Percentage of Boys="+perb);

System.out.println("Percentage of girls="+perb);

}

}n:

Similar questions