English

In an election, there are two candidates X and Y. On the election day, 80% of the voters go for polling, out of which 60% vote for X. - Computer Applications

Advertisements
Advertisements

Question

In an election, there are two candidates X and Y. On the election day, 80% of the voters go for polling, out of which 60% vote for X. Write a program to take the number of voters as input and calculate:

  1. number of votes received by X.
  2. number of votes received by Y. 
Answer in Brief

Solution

import java.utiL*;
class U5_Q1{ 
public static void main(String args[])
{Scanner obj = new Scanner(System.in);
System.out.println("Enter the number of voters");
long v1;
double v2, x, y;
vl = obj.nextlnt(); // Input - eligible voters 
v2 = (80.0 / 100) * v1; // 80% of voters who polled
x = (60.0 / 100) * v2; // 60% of votes 
y = v2 − x; // remaining votes 
System.out.println(''No. of votes secured by x: " + (long)x);
System.out.println(''No. of votes secured by y: " + (long)y); 
}}
shaalaa.com
  Is there an error in this question or solution?
Chapter 1.06: Input in Java - EXERCISES [Page 66]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.06 Input in Java
EXERCISES | Q V. 1. | Page 66
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×