hello i am trying to got this program i am doing for school to work. i have tried like 50 different things and can not get it to work. i am very frustrated is anyone could help me!
The output needs to look like this:
Candidate Votes Percentage
Aubrey 616618 49.71%
Martinez 623926 50.29%
TOTAL VOTES 1240544 100.00%
THIS IS WHAT I HAVE (its a mess)
//Katherine Brewer
// December 12, 2012
//PrimaryElection
import java.util.Scanner; //Brings in a libary that is needed for the Scanner class
import java.text.*;
public class PrimaryElection
{
static public void customFormat (String pattern, double value )
{
DecimalFormat myFormatter = new DecimalFormat(pattern);
String output = myFormatter.format(value);
System.out.println(output);
}
public static void main(String[]arge)
{
int nya; //New york votes
int nym; //New your votes
int nja; //New jersey votes
int njm; //New jersey votes
int ca; //Connecticut votes
int cm; //Connecticut votes
double totalsAubrey; //Total aurbrey
double totalsMartinez; //Total Martinez
double totals; //Total
double PercentagesAubrey; //Percents
double PercentagesMartinez; //Percents
double TotalPercentages; //Percents
Scanner keyboard=new Scanner(System.in);
//Get votes for Aubrey and Martinez in New york.
System.out.print(" election results for New York?");
System.out.println();
System.out.println("Aubrey:");
nya=keyboard.nextInt();
System.out.println();
System.out.println("Martinez:");
nym=keyboard.nextInt();
System.out.println();
//Get votes for Aubrey and Martinez in New Jersey.
System.out.print("election results in New Jersey?");
System.out.println();
System.out.println("Aubrey:");
nja=keyboard.nextInt();
System.out.println("Martinez:");
njm=keyboard.nextInt();
System.out.println();
//Get votes for Aubrey and Martinez in Connecticut.
System.out.print(" election results in Connecticut?");
System.out.println();
System.out.println("Aubrey:");
ca=keyboard.nextInt();
System.out.println("Martinez:");
cm=keyboard.nextInt();
System.out.println();
//Total votes for Aubrey
totalsAubrey = nya + nja + ca;
//Total votes for Martinez
totalsMartinez = nym + njm + cm;
//Display the resulting information.
System.out.println("Totals");
totals = nya + nja + ca + nym + njm + cm;
System.out.println("TotalPercentages");
System.out.print(nya + nja + ca);
System.out.print(nym + njm +cm);
System.out.print("TOTAL VOTES");
System.out.print(totalsAubrey + totalsMartinez);
//int at = (totalsAubrey/totals);
//int mt = (totalsMartinez/totals);
//customFormat("##.#",at);
System.out.print("Percentages Aubrey");
System.out.print("Percentages Martinez");
}
}
System.out.println("Canidate" + " " + "Votes" + " " + "Percentage");
System.out.println();
System.out.println("Aubrey" + " " + totalsAubrey PercentagesAubrey);
System.out.println();
System.out.println("Martinez" + " " + totalsMartinez PercentagesMartinez);
System.out.println();
System.out.printf("TOTAL VOTES" + " " + total TotalPercentages);