473,785 Members | 2,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

class interface or enum expected???

16 New Member
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 16271
Ganon11
3,652 Recognized Expert Specialist
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 Recognized Expert MVP
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
1335
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 trying to work my way through the idea of the class, especially the one, that uses a template parameter for the enumeration value, in the hopes of getting an enum that enumerated through std::strings. The whole idea is to keep a base class with...
1
4698
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. The enum is *public* in other words. What I find is that while the compiler allows the enum declaration within the abstract class, it turns out that the enum type isn't visible from outside the class. It is visible from within descendant...
12
1880
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 interface, though I know the basis of interfaces.
14
1991
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
2239
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 all have a different enumeration in them called Properties. I want to basically have a variable The_Class that I can dynamically point to either Class_A, Class_B, or Class_C and then do The_Class.properties to get the correct enumeration. How...
10
3906
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. --Randy Yates
1
2461
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 installed the boost library. This is using gcc under FC3.
2
2120
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 installed the boost library. This is using gcc under FC3.
2
10354
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 Class Library code, I have tried to put a DllImport to the Win32 function MessageBox. Just to test out the DllImport functionality before I add my custom functions that I want to wrap.
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8973
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.