Results 1 to 16 of 16
  1. #1
    shongo is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Default almost done...beginner needs help plz..

    need this program to show each category individually...cant do it at all..been at it a week....must be me && and || signs...i think...plz can someone help me as im really stuck now...thank you so much..


    import java.util.Scanner;

    public class assignmentquestion3 {

    public static Scanner key=new Scanner(System.in);

    public static void main(String []args){

    int fullfee=800,newfullfee=3800,associatefee=200,newla diesfee= 2350,ladiesfee= 350,under18fee = 175;
    int selectcat=0;
    int reply = 0;
    int addmember=0;
    int currentfulltotalmem=0,newfulltotalmem=0,associatet otalmem=0,ladiestotalmem=0,under18totalmem=0;
    int assoctotalcash=0,ladiestotalcash=0,under18totalcas h=0;
    int fullprepay=150;
    int ladiesfull=2500;
    int completefull = 0;
    int ladiescurrent=500;
    int under18=175;

    //Main introduction screen for the user and selections available. do while loops only allowing numbers 1,2,3 or 4.
    do{
    do{
    System.out.printf("\n\t %90s","********************Membership Rates For The Golf Club********************");
    System.out.printf("\n\n %105s","This program will allow users to enter details of members as well as calculating and.");
    System.out.printf("\n%106s","outputing the total amount each member should pay. The program allows users to view the");
    System.out.printf("\n%106s","total number of members in each category and the total income for each category.");
    System.out.printf("\n\n\t %75s","Please select your membership category: ");
    System.out.printf("\n\n\t %68s","Please press '1' for FULL");
    System.out.printf("\n\n\t %68s","Please press '2' for ASSOCIATE");
    System.out.printf("\n\n\t %68s","Please press '3' for LADIES");
    System.out.printf("\n\n\t %68s","Please press '4' for UNDER 18");
    System.out.printf("\n\n\t %68s","Please enter 1,2,3 or 4: ");
    selectcat=key.nextInt();
    }while (selectcat>4 || selectcat<1);


    do{
    System.out.printf("\n\n\t %75s","Are you a Current Member (press 1) or a New Member (press 2): ");
    reply=key.nextInt();
    }while (reply<1 || reply>2);



    //if number '1' for 'FULL' category is selected by the user and reply is 'yes'(1) then new full member fee is shown to user







    if (selectcat==1 ||reply==1)

    {
    System.out.printf("\n\n\t %68s","CURRENT FULL MEMBERSHIP SELECTED");

    System.out.printf("\n\n\t %68s","Current full membership fees yearly are "+fullfee+"");
    System.out.printf("\n\n\t %68s","Full members must also pre-pay "+fullprepay+" on a card can be used in the club facilities such as bar and shop ");
    System.out.printf("\n\n\t %72s","The total of this membership is: "+fullfee+"");

    currentfulltotalmem=currentfulltotalmem+1;

    System.out.printf("\n\n\t %72s","The total number of 'CURRENT FULL MEMBERSHIPS = "+currentfulltotalmem+"");


    completefull=completefull+fullfee;
    System.out.printf("\n\n\t %68s","The total amount of income for 'FULL MEMBERSHIPS' within the club = "+completefull+"");



    }


    //if number '1' is selected by the user and reply is 'no' (2) then full member fee is shown to user
    else if (selectcat==1 &&reply==2)

    {
    System.out.printf("\n\n\t %68s","NEW FULL MEMBERSHIP SELECTED");
    System.out.printf("\n\n\t %68s","Full membership fees yearly are "+newfullfee+"");



    newfulltotalmem=newfulltotalmem+1;

    System.out.printf("\n\n\t %68s","The total number of 'NEW FULL MEMBERSHIPS = "+newfulltotalmem+"");



    completefull=completefull+newfullfee;
    System.out.printf("\n\n\t %68s","The total amount of income for 'FULL MEMBERSHIPS' within the club = "+completefull+"");



    }



    //if number '2' is selected by the user then associate member fee is shown to user

    if (selectcat==2 &&(reply==1 || reply==2))

    {
    System.out.printf("\n\n\t %75s","ASSOCIATE MEMBERSHIP SELECTED");
    System.out.printf("\n\n\t %75s","ASSOCIATE membership fees yearly are "+associatefee+"");


    associatetotalmem=associatetotalmem+1;

    System.out.printf("\n\n\t %75s","The total number of 'ASSOCIATE MEMBERSHIPS' WITHIN THE CLUB = "+associatetotalmem+"");


    assoctotalcash=assoctotalcash+associatefee;
    System.out.printf("\n\n\t %68s","The total amount of income for 'ASSOCIATE MEMBERSHIPS' within the club = "+assoctotalcash+"");




    }


    //if number '3' is selected by the user and reply is 'yes' then new ladies member fee is shown to user

    if (selectcat==3 &&reply==1)

    {
    System.out.printf("\n\n\t %68s","LADIES CURRENT MEMBERSHIP SELECTED");
    System.out.printf("\n\n\t %68s","Ladies full membership fees yearly are "+ladiesfee+"");
    System.out.printf("\n\n\t %68s","Ladies must also pre-pay "+fullprepay+" on a card can be used in the club facilities such as bar and shop ");
    System.out.printf("\n\n\t %68s","The total of this membership is: "+ladiescurrent+"");


    ladiestotalmem=ladiestotalmem+1;

    System.out.printf("\n\n\t %75s","The total number of 'LADIES MEMBERSHIPS' WITHIN THE CLUB = "+ladiestotalmem+"");

    ladiestotalcash=ladiestotalcash+ladiescurrent;
    System.out.printf("\n\n\t %68s","The total amount of income for 'LADIES MEMBERSHIPS' within the club = "+ladiestotalcash+"");








    }

    //if number '3' is selected by the user and reply is 'no' then the current ladies member fee is shown to user
    else
    if (selectcat==3 && reply==2)

    {
    System.out.printf("\n\n\t %68s","LADIES NEW MEMBERSHIP SELECTED");
    System.out.printf("\n\n\t %68s","LADIES NEW MEMBERSHIP fees yearly are "+newladiesfee+"");
    System.out.printf("\n\n\t %68s","Ladies must also pre-pay "+fullprepay+" on a card can be used in the club facilities such as bar and shop ");
    System.out.printf("\n\n\t %68s","The total of this membership is: "+ladiesfull+"");

    ladiestotalmem=ladiestotalmem+1;

    System.out.printf("\n\n\t %75s","The total number of 'LADIES MEMBERSHIPS' within the club = "+ladiestotalmem+"");

    ladiestotalcash=ladiestotalcash+ladiesfull;

    System.out.printf("\n\n\t %68s","The total amount of income for 'LADIES MEMBERSHIPS' within the club = "+ladiestotalcash+"");

    }


    //if number '4' is selected by the user then under 18 member fee is shown to user

    else if (selectcat==4 &&(reply==1||reply==2))

    {
    System.out.printf("\n\n\t %75s","UNDER 18 MEMBERSHIP SELECTED");
    System.out.printf("\n\n\t %75s","UNDER 18 yearly membership fees are "+under18fee+"");}
    System.out.printf("\n\n\t %68s","The total of this membership is: "+under18+"");

    under18totalmem=under18totalmem+1;

    System.out.printf("\n\n\t %75s","The total number of 'UNDER 18 MEMBERSHIPS' within the club = "+under18totalmem+"");

    under18totalcash=under18totalcash+under18;

    System.out.printf("\n\n\t %68s","The total amount of income for 'UNDER 18 MEMBERSHIPS' within the club = "+under18totalcash+"");











    //allowing user to select '0' to add another member or any other key to exit program
    System.out.printf("\n\n\t %68s","Please Press '0' to add another member or any other key to exit.: ");
    addmember=key.nextInt();



    }while (addmember==0 ||addmember>1);}}




























    //












    //

  2. #2
    ankitmcgill is offline Member
    Join Date
    Nov 2008
    Posts
    22
    Rep Power
    0

    Default

    u got to be kidding .. you expect someone to go through pages of your code ? first identify the portion that does not seem to be working and then ask for help

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    See dup post:
    really stuck now..

    Please post on the same thread. Don't start new ones for same problem

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Can you specifically ask your question with the specific code segment? Did you get any error message there, if so can you post full error message here?

    Please don't post the same thread several times.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    A great resource that has helped me and will probably help you is an article entitled How To Ask Questions The Smart Way. It will tell you how to formulate your questions so that they are in fact answerable. Good luck.

  6. #6
    J-Live is offline Member
    Join Date
    Oct 2008
    Posts
    24
    Rep Power
    0

    Default

    import java.util.Scanner;

    public class assignmentquestion3 {

    public static Scanner key = new Scanner(System.in);

    public static void main(String []args){

    int fullfee = 800, newfullfee = 3800, associatefee = 200, newladiesfee = 2350, ladiesfee = 350, under18fee = 175;
    int selectcat = 0;
    int reply = 0;
    int addmember = 0;
    int currentfulltotalmem = 0, newfulltotalmem = 0, associatetotalmem = 0,ladiestotalmem = 0,under18totalmem = 0;
    int assoctotalcash=0,ladiestotalcash=0,under18totalcas h=0;
    int fullprepay=150;
    int ladiesfull=2500;
    int completefull = 0;
    int ladiescurrent=500;
    int under18=175;

    //Main introduction screen for the user and selections available. do while loops only allowing numbers 1,2,3 or 4.
    do{
    do{
    System.out.printf("\n\t %90s","********************Membership Rates For The Golf Club********************");
    System.out.printf("\n\n %105s","This program will allow users to enter details of members as well as calculating and.");
    System.out.printf("\n%106s","outputing the total amount each member should pay. The program allows users to view the");
    System.out.printf("\n%106s","total number of members in each category and the total income for each category.");
    System.out.printf("\n\n\t %75s","Please select your membership category: ");
    System.out.printf("\n\n\t %68s","Please press '1' for FULL");
    System.out.printf("\n\n\t %68s","Please press '2' for ASSOCIATE");
    System.out.printf("\n\n\t %68s","Please press '3' for LADIES");
    System.out.printf("\n\n\t %68s","Please press '4' for UNDER 18");
    System.out.printf("\n\n\t %68s","Please enter 1,2,3 or 4: ");
    selectcat = key.nextInt();
    }while (selectcat > 4 || selectcat < 1);


    do{
    System.out.printf("\n\n\t %75s","Are you a Current Member (press 1) or a New Member (press 2): ");
    reply = key.nextInt();
    }while (reply < 1 || reply > 2);



    //if number '1' for 'FULL' category is selected by the user and reply is 'yes'(1) then new full member fee is shown to user







    if (selectcat == 1 && reply == 1)

    {
    System.out.printf("\n\n\t %68s","CURRENT FULL MEMBERSHIP SELECTED");

    System.out.printf("\n\n\t %68s","Current full membership fees yearly are " + fullfee + "");
    System.out.printf("\n\n\t %68s","Full members must also pre-pay " + fullprepay + " on a card can be used in the club facilities such as bar and shop ");
    System.out.printf("\n\n\t %72s","The total of this membership is: " + fullfee + "");

    currentfulltotalmem = currentfulltotalmem + 1;

    System.out.printf("\n\n\t %72s","The total number of 'CURRENT FULL MEMBERSHIPS = " + currentfulltotalmem + "");


    completefull = completefull + fullfee;
    System.out.printf("\n\n\t %68s","The total amount of income for 'FULL MEMBERSHIPS' within the club = " + completefull + "");



    }


    //if number '1' is selected by the user and reply is 'no' (2) then full member fee is shown to user
    else if (selectcat == 1 && reply == 2)

    {
    System.out.printf("\n\n\t %68s","NEW FULL MEMBERSHIP SELECTED");
    System.out.printf("\n\n\t %68s","Full membership fees yearly are " + newfullfee + "");



    newfulltotalmem = newfulltotalmem + 1;

    System.out.printf("\n\n\t %68s","The total number of 'NEW FULL MEMBERSHIPS = " + newfulltotalmem + "");



    completefull = completefull + newfullfee;
    System.out.printf("\n\n\t %68s","The total amount of income for 'FULL MEMBERSHIPS' within the club = " + completefull + "");



    }



    //if number '2' is selected by the user then associate member fee is shown to user

    if ((selectcat == 2) && (reply == 1 || reply == 2))

    {
    System.out.printf("\n\n\t %75s","ASSOCIATE MEMBERSHIP SELECTED");
    System.out.printf("\n\n\t %75s","ASSOCIATE membership fees yearly are "+associatefee+"");


    associatetotalmem = associatetotalmem + 1;

    System.out.printf("\n\n\t %75s","The total number of 'ASSOCIATE MEMBERSHIPS' WITHIN THE CLUB = " + associatetotalmem + "");


    assoctotalcash = assoctotalcash + associatefee;
    System.out.printf("\n\n\t %68s","The total amount of income for 'ASSOCIATE MEMBERSHIPS' within the club = " +assoctotalcash + "");




    }


    //if number '3' is selected by the user and reply is 'yes' then new ladies member fee is shown to user

    if (selectcat == 3 && reply == 1)

    {
    System.out.printf("\n\n\t %68s","LADIES CURRENT MEMBERSHIP SELECTED");
    System.out.printf("\n\n\t %68s","Ladies full membership fees yearly are " + ladiesfee + "");
    System.out.printf("\n\n\t %68s","Ladies must also pre-pay " + fullprepay + " on a card can be used in the club facilities such as bar and shop ");
    System.out.printf("\n\n\t %68s","The total of this membership is: " + ladiescurrent + "");


    ladiestotalmem = ladiestotalmem + 1;

    System.out.printf("\n\n\t %75s","The total number of 'LADIES MEMBERSHIPS' WITHIN THE CLUB = " + ladiestotalmem + "");

    ladiestotalcash = ladiestotalcash + ladiescurrent;
    System.out.printf("\n\n\t %68s","The total amount of income for 'LADIES MEMBERSHIPS' within the club = " + ladiestotalcash + "");








    }

    //if number '3' is selected by the user and reply is 'no' then the current ladies member fee is shown to user
    else
    if (selectcat == 3 && reply == 2)

    {
    System.out.printf("\n\n\t %68s","LADIES NEW MEMBERSHIP SELECTED");
    System.out.printf("\n\n\t %68s","LADIES NEW MEMBERSHIP fees yearly are " + newladiesfee + "");
    System.out.printf("\n\n\t %68s","Ladies must also pre-pay " + fullprepay + " on a card can be used in the club facilities such as bar and shop ");
    System.out.printf("\n\n\t %68s","The total of this membership is: " + ladiesfull + "");

    ladiestotalmem = ladiestotalmem + 1;

    System.out.printf("\n\n\t %75s","The total number of 'LADIES MEMBERSHIPS' within the club = "+ladiestotalmem+"");

    ladiestotalcash = ladiestotalcash + ladiesfull;

    System.out.printf("\n\n\t %68s","The total amount of income for 'LADIES MEMBERSHIPS' within the club = "+ladiestotalcash+"");

    }


    //if number '4' is selected by the user then under 18 member fee is shown to user

    else if ((selectcat == 4) && (reply == 1 || reply == 2))

    {
    System.out.printf("\n\n\t %75s","UNDER 18 MEMBERSHIP SELECTED");
    System.out.printf("\n\n\t %75s","UNDER 18 yearly membership fees are "+under18fee+"");
    System.out.printf("\n\n\t %68s","The total of this membership is: "+under18+"");

    under18totalmem = under18totalmem + 1;

    System.out.printf("\n\n\t %75s","The total number of 'UNDER 18 MEMBERSHIPS' within the club = "+under18totalmem+"");

    under18totalcash = under18totalcash+under18;

    System.out.printf("\n\n\t %68s","The total amount of income for 'UNDER 18 MEMBERSHIPS' within the club = "+under18totalcash+"");


    }








    //allowing user to select '0' to add another member or any other key to exit program
    System.out.printf("\n\n\t %68s","Please Press '0' to add another member or any other key to exit.: ");
    addmember = key.nextInt();



    }while (addmember == 0);}}

    Not sure what your question was, but based on your code comments, that should put you in the right direction. Get an IDE. All your mistakes were small and wouldn't be picked up by the compiler.

  7. #7
    shongo is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Default

    im so sorry guys for not showing my code problems first to...



    the problem is :

    to produce a program which will show membership rates for a golf club..



    membership yearly rate new member joining fee
    category

    full 650 3000
    associate 200
    ladies 350 2000
    under 18 175

    new members must pay a joining fee in addition to the yearly rate as shown

    full/ladies members also prepay 150

    write a program which will enter details of members,calculate and output the total amount each member should pay.

    output number of members in each category
    the total income for each category....

  8. #8
    shongo is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Default

    the problem im having is whenever i make the choices 1,2,3,4 (CATEgorys) AND hit 1 or 2(current or new member selections) it brings up more than one category...

    for example when i hit 1(Category full) and 1(current member)..it displays this:




    Are you a Current Member (press 1) or a New Member (press 2): 1


    CURRENT FULL MEMBERSHIP SELECTED

    Current full membership fees yearly are 800

    Full members must also pre-pay 150 on a card can be used in the club facilities such as bar and shop

    The total of this membership is: 800

    The total number of 'CURRENT FULL MEMBERSHIPS = 1

    The total amount of income for 'FULL MEMBERSHIPS' within the club = 800

    The total of this membership is: 175

    The total number of 'UNDER 18 MEMBERSHIPS' within the club = 1

    The total amount of income for 'UNDER 18 MEMBERSHIPS' within the club = 175

    Please Press '0' to add another member or any other key to exit.:



    under 18 membership as well?...does this for other selections too...is it my arithmetic operators?....my if loops?...

  9. #9
    shongo is offline Member
    Join Date
    Nov 2008
    Posts
    5
    Rep Power
    0

    Default

    i am using the eclippse program for the problem...any help would be greatly appreciated guys...once again im sorry if i upset anyone yesterday...just that im really lost now with this simple java program...just new to java and find it hard but really want to learn it well.thank you

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    All your comments and code segments are really mess here. Can you explain what you want to do, rather explaining different codes. What you application going to do? Start form the beginning and break your application into simple steps, and work out one step at a time. Sure, we can help you to do this.

  11. #11
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    6

    Default

    You can try ditching the use of compound conditional statements using && and || by using nested if-statements. Perhaps that will help you organize your program and thoughts better. Just a suggestion, though.

    Java Code:
    if(stmt1 && stmt2) {
    } else ...
    works the same as

    Java Code:
    if(stmt1) {
       if(stmt2) {
       } else ...
    } else ...

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Not true.
    The two elses are not the same as the single else.

  13. #13
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    6

    Default

    Haha, true. The outer else wouldn't be there.

  14. #14
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    6

    Default

    Haha, nevermind, they aren't really the same. I just wanted to give him/her a different format that looked better suited for the task at hand, creating a series of if-else if's based on the same 2 variables

  15. #15
    J-Live is offline Member
    Join Date
    Oct 2008
    Posts
    24
    Rep Power
    0

    Default

    Quote Originally Posted by shongo View Post
    i am using the eclippse program for the problem...any help would be greatly appreciated guys...once again im sorry if i upset anyone yesterday...just that im really lost now with this simple java program...just new to java and find it hard but really want to learn it well.thank you
    Run the code I posted above. I modified the code slightly. Your program kept displaying the under 18 information because of the placement of the bracket, if I remember correctly. Logic errors are hard to locate. I personally try to comment the end of everything with a bracket. LOL

    (while something blah)
    {
    }// end while something blah

    if(something else)
    {
    }// end if

    Print statements can help too.

  16. #16
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by emceenugget View Post
    Haha, nevermind, they aren't really the same. I just wanted to give him/her a different format that looked better suited for the task at hand, creating a series of if-else if's based on the same 2 variables
    Basically logical operators are introduce to avoid complex if-else statements. Because nested conditional statements(if-else) more that three times is not a good programming practice.

Similar Threads

  1. Help with Beginner exercise.
    By Trunksten in forum New To Java
    Replies: 1
    Last Post: 07-10-2008, 05:40 AM
  2. total beginner needs little help
    By asambasamba in forum New To Java
    Replies: 1
    Last Post: 06-18-2008, 05:33 PM
  3. beginner to Java
    By notwist in forum New To Java
    Replies: 15
    Last Post: 04-18-2008, 09:41 AM
  4. Beginner-Moderate IDE
    By Hiro ZA in forum NetBeans
    Replies: 4
    Last Post: 01-26-2008, 06:16 AM
  5. beginner needs help with OBD-II input
    By andrewos in forum New To Java
    Replies: 3
    Last Post: 07-30-2007, 09:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •