Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: annoying error.

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default annoying error.

    im sure its just a simple error but i can't see it
    where it is yellow i get '(' expected.. any help appreciated.

    public class ProcessCurrency {
     
        static final int MINICOM = 500;
    [COLOR="Yellow"]    public static void main string(String[] argv) {[/COLOR] 
     
            double amtEx;
            double commission, cash;
            double totalAmt =0, totalSterling=0, totalCash=0, totalComm=0
            int transaction = 0;
     
            UserInput.prompt("currency to convert from");
            sterling currency =UserInput.readString();
     
            UserInput.prompt("Rate of exchange to sterling pence");
            double exRate = UserInput.readDouble();
     
            UserInput.prompt("Amount to Exchange");
            amtEx = UserInput.readDouble();
     
                while (amtEx >0) {
     
                    double penceAmt = (amtEx/exRate);
                    int pAmt = (int) (penceAmt *100);
                    double sterling = pAmt/100;
     
                    System.out.println(amtEx + " " + currency + " is " + sterling/100 = "pence")
     
                    if (sterling<=MINICOMM) {
                       System.out.println("Ammount to small"); 
                    }//end if
     
                    else {
                        commission = (sterling * commRate/100);
     
                        if(commission <MINICOMM) {
                            commission = MINICOMM;
     
                        }
     
                        System,out.println("commission " + commission/100 + " GDP")
     
                        cash = sterling - commission; 
     
                        System.out.println (" ; payout " = cash/100 + " GDP");
     
                        totalAmt = totalAmt + amtEx;
                        totalSterling = totalSterling + sterling;
                        totalCash = totalCash + cash; 
                        totalComm = totalcomm + commission;
                        transaction++;
     
                    }//end else
     
                    System.out.println("\nAmount to exchange2");
                    amtEx = UserInput.readDouble();
     
                }//end while
     
                System.out.println (" Transactions " + transaction );
                System.out.println (" Total " + currency + " recieved " + totalAmt);
                System.out.println (" Total sterling value " + totalSterling / 100);
                System.out.println (" Total handouts " + totalCash/ 100);
                System.out.println (" Total commission " + totalComm / 100);
                System.out.println (" Average handout " + totalCash / 100 / transaction);
     
                System.out.println ( currency + " per pound " + totalAmt * 100 / totalCash );
     
            }//end of main
     
        }// end of class
     
     
    // Put your local declarations here
     
        // Prompt and read
     
        // Compute and print
     
        } // end of main
     
    } // end class
    Last edited by Json; January 24th, 2010 at 10:16 AM. Reason: Please use code tags


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: annoying error.

    This is because that line needs to look like this.

        public static void main(String[] argv) {

    // Json

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: annoying error.

    now im getting a new error where its red it says cannot find symbol - class sterling.



    public class ProcessCurrency {
     
        static final int MINICOM = 500;
        public static void main(String[] argv) {
     
            double amtEx;
            double commission, cash;
            double totalAmt =0, totalSterling=0, totalCash=0, totalComm=0;
            int transaction = 0;
     
     
            UserInput.prompt("currency to convert from");
    [COLOR="DarkRed"]        sterling currency =UserInput.readString();[/COLOR] 
     
            UserInput.prompt("Rate of exchange to sterling pence");
            double exRate = UserInput.readDouble();
     
            UserInput.prompt("Amount to Exchange");
            amtEx = UserInput.readDouble();
     
                while (amtEx >0) {
     
                    double penceAmt = (amtEx/exRate);
                    int pAmt = (int) (penceAmt *100);
                    double sterling = pAmt/100;
     
                    System.out.println(amtEx + " " + currency + " is " + sterling/100 = "pence");
     
                    if (sterling<=MINICOMM) {
                       System.out.println("Ammount to small"); 
                    }//end if
     
                    else {
                        commission = (sterling * commRate/100);
     
                        if(commission <MINICOMM) {
                            commission = MINICOMM;
     
                        }
     
                        System.out.println("commission " + commission/100 + " GDP");
     
                        cash = sterling - commission; 
     
                        System.out.println (" ; payout " = cash/100 + " GDP");
     
                        totalAmt = totalAmt + amtEx;
                        totalSterling = totalSterling + sterling;
                        totalCash = totalCash + cash; 
                        totalComm = totalcomm + commission;
                        transaction++;
     
                    }//end else
     
                    System.out.println("\nAmount to exchange2");
                    amtEx = UserInput.readDouble();
     
                }//end while
     
                System.out.println (" Transactions " + transaction );
                System.out.println (" Total " + currency + " recieved " + totalAmt);
                System.out.println (" Total sterling value " + totalSterling / 100);
                System.out.println (" Total handouts " + totalCash/ 100);
                System.out.println (" Total commission " + totalComm / 100);
                System.out.println (" Average handout " + totalCash / 100 / transaction);
     
                System.out.println ( currency + " per pound " + totalAmt * 100 / totalCash );
     
            }//end of main
     
        }// end of class
    Last edited by Freaky Chris; January 24th, 2010 at 02:26 PM.

  4. #4
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Location
    Wales, Bangor & England, Warwickshire
    Posts
    820
    My Mood
    Cynical
    Thanks
    7
    Thanked 104 Times in 90 Posts

    Default Re: annoying error.

    Do you have a class called sterling, or is it Sterling?
    chris[at]javaprogrammingforums[dot]com

    Prifysgol Bangor University, North Wales

  5. #5
    Junior Member
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: annoying error.

    the only class i have is totalSterling=0, but i've tried to create a variable sterling and it still gives an error.
    public class ProcessCurrency {
     
        static final int MINICOM = 500;
        public static void main(String[] argv) {
     
            double amtEx;
            double commission, cash;
            double totalAmt =0, totalSterling=0, totalCash=0, totalComm=0;
            int transaction = 0 ;
     
     
     
     
            UserInput.prompt("currency to convert from");
            Sterling currency =UserInput.readString();
     
            UserInput.prompt("Rate of exchange to sterling pence");
            double exRate = UserInput.readDouble();
     
            UserInput.prompt("Amount to Exchange");
            amtEx = UserInput.readDouble();
     
                while (amtEx >0) {
     
                    double penceAmt = (amtEx/exRate);
                    int pAmt = (int) (penceAmt *100);
                    double sterling = pAmt/100;
     
                    System.out.println(amtEx + " " + currency + " is " + sterling/100 = "pence");
     
                    if (sterling<=MINICOMM) {
                       System.out.println("Ammount to small"); 
                    }//end if
     
                    else {
                        commission = (sterling * commRate/100);
     
                        if(commission <MINICOMM) {
                            commission = MINICOMM;
     
                        }
     
                        System.out.println("commission " + commission/100 + " GDP");
     
                        cash = sterling - commission; 
     
                        System.out.println (" ; payout " = cash/100 + " GDP");
     
                        totalAmt = totalAmt + amtEx;
                        totalSterling = totalSterling + sterling;
                        totalCash = totalCash + cash; 
                        totalComm = totalcomm + commission;
                        transaction++;
     
                    }//end else
     
                    System.out.println("\nAmount to exchange2");
                    amtEx = UserInput.readDouble();
     
                }//end while
     
                System.out.println (" Transactions " + transaction );
                System.out.println (" Total " + currency + " recieved " + totalAmt);
                System.out.println (" Total sterling value " + totalSterling / 100);
                System.out.println (" Total handouts " + totalCash/ 100);
                System.out.println (" Total commission " + totalComm / 100);
                System.out.println (" Average handout " + totalCash / 100 / transaction);
     
                System.out.println ( currency + " per pound " + totalAmt * 100 / totalCash );
     
            }//end of main
     
        }// end of class
    Last edited by helloworld922; January 24th, 2010 at 04:25 PM. Reason: Please use [code] tags!

  6. #6
    Member
    Join Date
    Jan 2010
    Location
    Oxford, UK
    Posts
    30
    Thanks
    2
    Thanked 7 Times in 7 Posts

    Default Re: annoying error.

    You are trying to create a variable called 'currency' which can hold an object of type Sterling, but it seems you haven't written a class called Sterling, hence the compiler error.

  7. #7
    Junior Member
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: annoying error.

    how could i correct this without creating a new class, the classes i have used are Currency, ProcessCurrency and UserInput.

  8. #8
    Member
    Join Date
    Jan 2010
    Location
    Oxford, UK
    Posts
    30
    Thanks
    2
    Thanked 7 Times in 7 Posts

    Default Re: annoying error.

    I think you just want currency to be a String i.e.
    String currency =UserInput.readString();

  9. The Following User Says Thank You to Shambolic For This Useful Post:

    Json (January 25th, 2010)