473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

class interface or enum expected???

I have like atleast 15 errors that say class, interface, or enum expected and I have no idea what that means. Can someone tell me what it is and how I might be able to fix it?
Thank you.

- Manny

*Program Purpose: This program processes the results for the 2008 Democratic and/or Republican presidential
primary elections.


Expand|Select|Wrap|Line Numbers
  1.  
  2. import staugIO.StaugIO;
  3. public class Primaries2008{
  4.  
  5.  
  6.  
  7.     //DECLARE PRIVATE VARIABLES****************************************************************************************************
  8.     private int choice, count1 , count2, count3, count4, totalCount, whichPrimary, 
  9.             democraticPrimaryCount, republicanPrimaryCount;
  10.     private double candidate1, candidate2, candidate3, candidate4;
  11.     private char answer;
  12.     private char anotherVoter = 'V';
  13.     private boolean anotherPrimary = false;
  14.     private String tab5 = " ";
  15.     private String tab3 = " ";
  16.     private String democraticResults = "2008 Democratic Primary Preliminary Results";
  17.     private String republicanResults = "2008 Republican Primary Preliminary Results";
  18.     private StaugIO io;
  19.     private DecimalFormat percent = new DecimalFormatter("##0%");
  20.  
  21.  
  22.  
  23.     //FIRST LEVEL OF REFINEMENT METHODS*********************************************************************************************
  24.     public void beginPrimary()
  25.     {
  26.         do
  27.         {
  28.         int    totalCount = 0;
  29.         int count1 = 0;
  30.         int count2 = 0;
  31.         int count3 = 0;
  32.         int count4 = 0;
  33.         double candidate1 = 0.0;
  34.         double candidate2 = 0.0;
  35.         double candidate3 = 0.0;
  36.         double candidate4 = 0.0;
  37.  
  38.  
  39.  
  40.             do{
  41.                 private void selectPrimary()
  42.                 {//BEGIN selectPrimary
  43.                     if((whichPrimary <= 0 ) || (whichPrimary > 2));
  44.                     {
  45.                         io.writeInfo("Invalid primary choice!");
  46.                     }
  47.  
  48.                     else{
  49.                         switch(whichPrimary)
  50.                         {
  51.                             case 1: ++democraticPrimaryCount; break;
  52.                             case 2: ++republicanPrimaryCount; break;
  53.                         }
  54.                     }//END IF
  55.  
  56.                 }//END selectPrimary
  57.  
  58.  
  59.  
  60.  
  61.                     if((democraticPrimaryCount == 1) && (republicanPrimaryCount == 1));
  62.                     {
  63.                         anotherPrimary = false;
  64.                     } 
  65.  
  66.                     while ((whichPrimary <> 1 ) && (whichPrimary <> 2))
  67.  
  68.  
  69.  
  70.  
  71.                     do{
  72.                         if(whichPrimary == 1);
  73.                         {//BEGIN IF
  74.                             private democraticPrimary()
  75.                             {//BEGIN democraticPrimary
  76.                                 switch(choice)
  77.                                 {//BEGIN switch
  78.                                     case 1: io.writeInfo("1. Hillary Clinton"); break;
  79.                                     case 2: io.writeInfo("2. Barack Obama"); break; 
  80.                                     case 3: io.writeInfo("3. John Edwards"); break;
  81.                                     case 4: tallyVote();break;{
  82.                                     }
  83.  
  84.                                     default: io.writeInfo("Invalid candidate choice!"); break;
  85.                                     anotherVoter = 'v';
  86.  
  87.                                     }//END Switch
  88.  
  89.                                 }//END democraticPrimary
  90.  
  91.                             }//END IF
  92.  
  93.  
  94.                             if((choice > 0) && (choice < 5));
  95.                             {
  96.                                 answer = io.writeInfo("Thank you! Your vote has been recorded.\n\n");
  97.                                          io.writeInfo("Election Official:\n\n");
  98.                                          io.writeInfo("To reset for another primary enter 'P'.");
  99.                                          io.writeInfo("\nTo exit and get preliminary primary results enter 'E'.");
  100.                             }
  101.  
  102.  
  103.  
  104.                             if((answer == 'v') || (answer == 'V'))
  105.                             {
  106.                                 anotherVoter == answer;
  107.                             }
  108.                             else 
  109.                                 if((answer == 'p') || (answer == 'P'))
  110.                                 {
  111.                                     anotherVoter = 'e';
  112.                                     anotherPrimary = false;
  113.                                 }
  114.  
  115.                             while((anotherVoter == 'v') || (anotherVoter == 'V'));
  116.  
  117.                     }//END DO 
  118.  
  119.                             if(whichPrimary == 1)
  120.                             {
  121.                                 democraticPrimaryWinner();
  122.                             }
  123.  
  124.                             else
  125.                             {
  126.                                 republicanPrimaryWinner();
  127.                             }
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.                             while(anotherPrimary = true)
  135.  
  136.                             }//END DO
  137.  
  138.  
  139.                             if((democraticPrimaryCount == 1) && (republicanPrimaryCount == 1))
  140.                             {
  141.                                 io.writeInfo("\nTwo primaries have already been processed.");
  142.                                 io.writeInfo("\n\nPrimary election results will follow!");
  143.                                 io.writeInfo(democraticResults);
  144.                                 io.writeInfo(republicanResults);
  145.                             else
  146.                                 if(whichPrimary == 1)
  147.                                 {
  148.                                     io.writeInfo(democraticResults);
  149.                                     else 
  150.                                         io.writeInfo(republicanResults);
  151.                                 }
  152.  
  153.                             }
  154.                             }
  155.             }
  156.  
  157.     }//RETURN
  158.  
  159.  
  160.             //SECOND LEVEL OF REFINEMENT*******************************************************************************
  161.  
  162.  
  163.             private selectPrimary()
  164.             {//BEGIN selectPrimary
  165.  
  166.                 whichPrimary = io.writeInfo("Election Official: Which primary election are you setting for? ");
  167.                                io.writeInfo("\n\n1. Democratic Primary");
  168.                                  io.writeInfo("\n2. Republican Primary");
  169.  
  170.             }//RETURN selectPrimary
  171.  
  172.  
  173.  
  174.  
  175.             private democraticPrimary()
  176.             {//BEGIN democraticPrimary
  177.                 choice = io.writeInfo("ELECTION 2008 REPUBLICAN PRIMARY\n\n");
  178.                           io.writeInfo("1. Hillary Clinton\n");
  179.                            io.writeInfo("2. Barack Obama\n");
  180.                             io.writeInfo("3. John Endwards\n\n");
  181.  
  182.                           io.writeInfo("Enter the number for the presidential candidate of your choice: \n\n");
  183.             }//RETRUN democraticPrimary
  184.  
  185.  
  186.             private republicanPrimary()
  187.             {
  188.                 choice = io.writeInfo("ELECTION 2008 REPUBLICAN PRIMARY\n\n");
  189.                           io.writeInfo("1. Rudy Giuliani\n");
  190.                            io.writeInfo("2. Fred Thompson\n");
  191.                             io.writeInfo("3. Mitt Romney\n");
  192.                          io.writeInfo("4. John McCain\n\n");
  193.                           io.writeInfo("Enter the number for the presidential candidate of your choice: \n\n")
  194.  
  195.             }//RETURN republicanPrimary
  196.  
  197.  
  198.             private tallyVote()
  199.             {//BEGIN tallyVote
  200.                 switch(choice)
  201.                 {
  202.                     case 1: ++count1;break;
  203.                     case 2: ++count2;break;
  204.                     case 3: ++count3;break;
  205.                     case 4: ++count4;break;
  206.                 }
  207.                 ++totalCount;
  208.                 }//RETURN tallyVote
  209.  
  210.  
  211.  
  212.                 private democraticPrimaryWinner()
  213.                 {
  214.                     candidate1 = (double)(count1)/totalCount;
  215.                     candidate2 = (double)(count2)/totalCount;
  216.                     candidate3 = (double)(count3)/totalCount;
  217.  
  218.                     democraticResults += ("\n\n1. Hillary clinton" + tab5 + tab5 + percent.format(candidate1)
  219.                                       + "\n2. Barack Obama  " + tab5 + percent.format(candidate2)
  220.                                       + "\n3. John Edwards   " + tab5 + percent.format(candidate3) + "\n\n");
  221.  
  222.  
  223.                 }//RETURN democraticPrimaryWinner
  224.  
  225.  
  226.  
  227.                 private republicanPrimaryWinner()
  228.                 {
  229.                     candidate1 = (double)(count1)/totalCount;
  230.                     candidate2 = (double)(count2)/totalCount;
  231.                     candidate3 = (double)(count3)/totalCount;
  232.                     candidate4 = (double)(count4)/totalCount;
  233.  
  234.                     republicanResults += ("\n\n1. Fred Thompson" + tab5 + tab5 + percent.format(candidate2)
  235.                                       + "\n2. Rudy Giuliani" + tab5 + percent.format(candidate1)
  236.                                       + "\n3. Mitt Romney " + tab5 + percent.format(candidate3) + "\n\n"
  237.                                       + "\n4. John McCain     " + tab5 + tab5 percent.format(candidate4) + "\n\n");
  238.  
  239.  
  240.                 }//RETURN republicanPrimaryWinner
  241.  
  242.             }//RETURN beingPrimary
  243.  
  244.  
  245.                         }//END class PRIMARIES2008
  246.  
  247.  
  248.  
  249.  
  250.  
  251.     public static void main(String[] args) {
  252.  
  253.  
  254.  
  255.  
  256.     }
  257.  
  258.  
  259.  
Oct 10 '07 #1
2 16240
Ganon11
3,652 Expert 2GB
I'm sure our experts will be able to help you, but you need to post in the proper place. The Articles section has a different purpose than the regular Forums, and isn't the place for this kind of post. I'll move your post now.
Oct 10 '07 #2
JosAH
11,448 Expert 8TB
I have like atleast 15 errors that say class, interface, or enum expected and I have no idea what that means. Can someone tell me what it is and how I might be able to fix it?
Thank you.

- Manny
Your curly brackets don't match up; check each and every one of them, i.e each
{ needs a matching } somewhere down the code. Most editors can help you with
this boring little task.

kind regards,

Jos
Oct 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Brian Riis | last post by:
This all pertains to the above mentioned article. Anyone want to read it (it's rather neat, actually), here's the address: http://www.cuj.com/documents/s=8205/cujweb0305meynard/ Anyway, I was...
1
by: Bill Cohagan | last post by:
I've got an abstract class (say foo) and I'd like to define an Enum (say bar) within that class so that I can then refer to foo.bar.<one of the enum labels> from within other parts of the program....
12
by: craigkenisston | last post by:
Hi, I will use an example to do a simplified description of my problem, please don't laugh. I just "believe" I would have to use either interface or abstract classes, but I've not ever write an...
14
by: Lee Franke | last post by:
I can't seem to figure this one out. Here is my class structure namespace name { public class foo { } }
9
by: David A. Osborn | last post by:
I have a set of classes that each have an enumeration in them, and based on dynamic input I need to access a different enumeration. For example Three classes Class_A, Class_B, and Class_C that...
10
by: Randy | last post by:
Hi, Can anyone point me to a complete, compilable example of Besser's ENUM++ mechanism? I downloaded it from CUJ and gave it a try but got errors just trying to compile the header enum.h. ...
1
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
2
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
2
by: nospam | last post by:
Hello - I am getting a compile error "Expected class, delegate, enum". I am trying to create a Class Library in C# which wraps around an unmanaged DLL that manages a MIDI interface. In my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.