Velocity Reviews > how can i solve this problem " char a=keyboard.readInt();" possible loss of precissio

# how can i solve this problem " char a=keyboard.readInt();" possible loss of precissio

fernie.java
Junior Member
Join Date: Jan 2008
Posts: 1

 01-13-2008
import chn.util.*;
public class elections
{
public static void main(String[] args)
{
System.out.println("Fernie Rosas");
System.out.println("4th Period ");
System.out.println("January 6 2007");

ConsoleIO keyboard = new ConsoleIO();
System.out.println("");

int a=0;
int b=0;
int c=0;
int d=0;
int e=0;
int f=0;
int g=0;
int h=0;
int i=0;
int j=0;
int k=0;
int l=0;
int m=0;
int n=0;
int o=0;
int p=0;
{
System.out.println("enter 1 for John McCain");
System.out.println("enter 2 for Mitt Romney");
System.out.println("enter 3 for Alan Keyes");
System.out.println("enter 4 for Duncan Hunter");
System.out.println("enter 5 for Fred Thompson");
System.out.println("enter 6 for Bill Richardson");
System.out.println("enter 7 for Dennis Kucinich");
System.out.println("enter 8 for Rudy Giuliani");
System.out.println("enter 9 for John Edwards");
System.out.println("enter 10 for Mike Huckabee");
System.out.println("enter 11 for Ron Paul");
System.out.println("enter 12 for Chris Dodd");
System.out.println("enter 13 for Hillary Clinton");
System.out.println("enter 14 for Cynthia McKinney");
System.out.println("enter 15 for Barack Obama");
System.out.println("enter 16 for John Cox");
System.out.println(" now enter your vote(s)");

for (int z = 1 ; z <= 24 ; z++)
{

if(vote1==1)
a=a+1;
else if(vote1==2)
b=b+1;
else if(vote1==3)
c=c+1;
else if(vote1==4)
d=d+1;
else if(vote1==5)
e=e+1;
else if(vote1==6)
f=f+1;
else if(vote1==7)
g=g+1;
else if(vote1==
h=h+1;
else if(vote1==9)
i=i+1;
else if(vote1==10)
j=j+1;
else if(vote1==11)
k=k+1;
else if(vote1==12)
l=l+1;
else if(vote1==13)
m=m+1;
else if(vote1==14)
n=n+1;
else if(vote1==15)
o=o+1;
else if(vote1==16)
p=p+1;
}
}
System.out.println("THE PRESIDENT(S) OF THE UNITED STATES OF AMERICA IS(ARE)");

if(a>=b&&a>=c&&a>=d&&a>=e&&a>=f&&a>=g&&a>=h&&a>=i& &a>=j&&a>=k&&a>=l&&a>=m&&a>=n&&a>=o&&a>=p)
{ System.out.print("John McCain won ");
System.out.println(" won with "+ (a) + " votes");
}
if(b>=a&&b>=c&&b>=d&&b>=e&&b>=f&&b>=g&&b>=h&&b>=i& &b>=j&&b>=k&&b>=l&&b>=m&&b>=n&&b>=o&&b>=p)
{ System.out.print(" Mitt Romney");
System.out.println(" won with "+ (b) + " votes");
}
if(c>=b&&c>=a&&c>=d&&c>=e&&c>=f&&c>=g&&c>=h&&c>=i& &c>=j&&c>=k&&c>=l&&c>=m&&c>=n&&c>=o&&c>=p)
{ System.out.print("Alan Keyes");
System.out.println(" won with "+ (c) + " votes");
}
if(d>=b&&d>=c&&d>=a&&d>=e&&d>=f&&d>=g&&d>=h&&d>=i& &d>=j&&d>=k&&d>=l&&d>=m&&d>=n&&d>=o&&d>=p)
{ System.out.print("Duncan Hunter");
System.out.println(" won with "+ (d) + " votes");
}
if(e>=b&&e>=c&&e>=d&&e>=a&&e>=f&&e>=g&&e>=h&&e>=i& &e>=j&&e>=k&&e>=l&&e>=m&&e>=n&&e>=o&&e>=p)
{ System.out.print("Fred Thompson");
System.out.println(" won with "+ (e) + " votes");
}
if(f>=b&&f>=c&&f>=d&&f>=e&&f>=a&&f>=g&&f>=h&&f>=i& &f>=j&&f>=k&&f>=l&&f>=m&&f>=n&&f>=o&&f>=p)
{ System.out.print("Bill Richardson");
System.out.println(" won with "+ (f) + " votes");
}
if(g>=b&&g>=c&&g>=d&&g>=e&&g>=f&&g>=a&&g>=h&&g>=i& &g>=j&&g>=k&&g>=l&&g>=m&&g>=n&&g>=o&&g>=p)
{ System.out.print("Dennis Kucinich");
System.out.println(" won with "+ (g) + " votes");
}
if(h>=b&&h>=c&&h>=d&&h>=e&&h>=f&&h>=g&&h>=a&&h>=i& &h>=j&&h>=k&&h>=l&&h>=m&&h>=n&&h>=o&&h>=p)
{ System.out.print(" Rudy Giuliani");
System.out.println(" won with "+ (h) + " votes");
}
if(i>=b&&i>=c&&i>=d&&i>=e&&i>=f&&i>=g&&i>=h&&i>=a& &i>=j&&i>=k&&i>=l&&i>=m&&i>=n&&i>=o&&i>=p)
{ System.out.print("John Edwards");
System.out.println(" won with "+ (i) + " votes");
}
if(j>=b&&j>=c&&j>=d&&j>=e&&j>=f&&j>=g&&j>=h&&j>=i& &j>=a&&j>=k&&j>=l&&j>=m&&j>=n&&j>=o&&j>=p)
{ System.out.print(" Mike Huckabee");
System.out.println(" won with "+ (j) + " votes");
}
if(k>=b&&k>=c&&k>=d&&k>=e&&k>=f&&k>=g&&k>=h&&k>=i& &k>=j&&k>=a&&k>=l&&k>=m&&k>=n&&k>=o&&k>=p)
{ System.out.print(" Ron Paul");
System.out.println(" won with "+ (k) + " votes");
}
if(l>=b&&l>=c&&l>=d&&l>=e&&l>=f&&l>=g&&l>=h&&l>=i& &l>=j&&l>=k&&l>=a&&l>=m&&l>=n&&l>=o&&l>=p)
{ System.out.print(" Chris Dodd");
System.out.println(" won with "+ (l) + " votes");
}
if(m>=b&&m>=c&&m>=d&&m>=e&&m>=f&&m>=g&&m>=h&&m>=i& &m>=j&&m>=k&&m>=l&&m>=a&&m>=n&&m>=o&&m>=p)
{ System.out.print(" Hillary Clinton");
System.out.println(" won with "+ (m) + " votes");
}
if(n>=b&&n>=c&&n>=d&&n>=e&&n>=f&&n>=g&&n>=h&&n>=i& &n>=j&&n>=k&&n>=l&&n>=m&&n>=a&&n>=o&&n>=p)
{ System.out.print("Cynthia McKinney");
System.out.println(" won with "+ (n) + " votes");
}
if(o>=b&&o>=c&&o>=d&&o>=e&&o>=f&&o>=g&&o>=h&&o>=i& &o>=j&&o>=k&&o>=l&&o>=m&&o>=n&&o>=a&&o>=p)
{ System.out.print(" Barack Obama");
System.out.println(" won with "+ (o) + " votes");
}
if(p>=b&&p>=c&&p>=d&&p>=e&&p>=f&&p>=g&&p>=h&&p>=i& &p>=j&&p>=k&&p>=l&&p>=m&&p>=n&&p>=o&&p>=a)
{ System.out.print(" John Cox");
System.out.println(" won with "+ (p) + " votes");
}

}
}

the point is that the user has to insert a password so that he can vote but the password cannot be shown it could show symbols but not the actual password is there another way of doing this