Jump to content
  • Advertisement
Sign in to follow this  
l jsym l

java help please!

This topic is 3208 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

import java.util.*;

public class Election
{
	static Scanner console = new Scanner(System.in);
	
	public static void main(String[] args)
	{
		String name;
		int vote;
		
		String[] names = new String[5];
		int[] votes = new int[5];
		
		for (int i = 0; i < 5; i++)
			{
				System.out.print("Please enter the candidates last name: ");
				name = console.next();
				
				System.out.print("Please enter the candidates total votes: ");
				vote = console.nextInt();
				
				inputC(name, vote);
				
			}
		
		percent(votes);
	
	}	
	
	
	public static void inputC(String a, int b)
	{
		String[] names = new String[5];
		int[] votes = new int[5];
	
		String name = a;
		int vote = b;
		
		
		
		for (int i = 0; i < names.length; i++)
				names = name;
			
			
		for (int d = 0; d < votes.length; d++)
				votes[d] = vote;
			
			
		}
		
		
		
		
		public static void percent(int[] v1)
		{
			double[] percent = new double[5];
			
			double percents;
			
			for (int i = 0; i < v1.length; i++)
					int sum = sum + v1;
				
			for (int i = 0; i < v1.length; i ++)
			
				for (int d = 0; d < percent.length; d++)
					percents = (v1/sum);
					percent[d] = percents;
		}	
	
	
}
I'm doing a program for a college assignment and i seem to get an error of this: Election.java:62: '.class' expected int sum = sum + v1; ^ Election.java:62: not a statement int sum = sum + v1; ^ 2 errors but I'm not for sure why i am getting this error. If anyone knows will you please let me know. It would be great. Also if you see anything else wrong with my code..it's not completely done. I have a lot of work to do but im stuck on this problem.

Share this post


Link to post
Share on other sites
Advertisement
Umm, yeah... There's quite a few things wrong, most prominently your inconsistent use of the for statement.

But schoolwork is meant to help you gain code creation (and debugging) experience, not help us do code reviews.

Share this post


Link to post
Share on other sites

This topic is 3208 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!