IN AN ELECTION THERE ARE TWO CANDIDATES X AN Y . ON THE ELECTION DAY 80PERCENT OF THE VOTERS GO FOR POLLING OUT OF WHICH 60PERCEENT VOTE FOR X . WRITE A PROGRAM TO TAKE THE NUMBER OF VOTERS AS INPUT AND CALCULATE : 1] NUMBER OF VOTES X GET 2] NUMBER OF VOTES Y GET
Answers
Answered by
2
import java.uril.*;
public class Votes
{
public static void main (String args [])
{
Scanner sc=new Scanner(System.in);
System.out.println("Please Enter The Number Of People");
int People = sc.nextInt();
int total_votes = ( People * 80 ) / 100 ;
int x_votes = ( total_votes * 60 ) / 100 ;
int y_votes = total_votes - x_votes ;
System.out.println("Total Voters :: "+ total_votes );
System.out.println("Votes For X :: "+ x_votes );
System.out.println("Votes For Y :: "+ y_votes );
sc.close();
}
}
Attachments:
Similar questions