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 4 of 4

Thread: doubts about boolean

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default doubts about boolean

    Hello folks,

    I have got this example here to develop in java JDK and run it on DCP,and I have some douts how to do it using the Boolean.

    Description

    Robert ( male ) is 10, Mary ( female ) is 25 and John ( male ) is 75
    Write a program that prints to the screen the information and a colour based on age and gender of each person:
    - Children ( age less or equal than 12 )
     Male: Light Blue
     Female: Light Pink
    - Adult ( age between 13 and 50 )
     Male: Blue
     Female: Red
    - Senior ( age greater 50 )
     Male: Green
     Female: White

    Output
    Robert ( Children - Male - 10 years old ) colour: Light Blue
    Mary.. ( Adult - Female - 25 years old ) colour: Red
    John.. ( Senior - Male - 75 years old ) colour: Green
    NOTE: The information about each person should come from variables !!! Do NOT hard code it !!!

    Thanks in advance for any help.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: doubts about boolean

    have some doubts how to do it using the Boolean.
    Please explain what problems you are having and post the code showing the problem.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: doubts about boolean

    Here where i am.I just don't know to to declare and encode the boolean.



    class BSLab2c{

    public static void main (String [] args){

    //Declare the variables
    String name1= "Roberto";
    String name2= "Mary";
    String name3= "Jonh";
    boolean= "Male";
    boolean= Female;
    String color1= "Light Blue";
    String color2= "Red";
    String color3= "Green";
    String color4= "Light Pink";
    String color5= "Blue";
    String color6= "Green";
    String color7= "White";
    int age1= 10;
    int age2= 25;
    int age3= 75;

    //Robert ( Children - Male - 10 years old ) colour: Light Blue

    System.out.print(name1 + " ");
    Syste.out.print("(" + gender1+ age1 + " " + "years old" + ")");

    if (age1< = 12){
    System.out.println("Children - Male");
    {
    {
    {

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: doubts about boolean

    Its the same syntax for most variables:
    THE_TYPE THE_VARIABLE_NAME
    optionally followed by = and an initial VALUE
    followed by ;

    The posted code does not have the variable names for the booleans.
    boolean variables can only have two values: true or false


    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. event handling doubts
    By Rakshith in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 24th, 2013, 12:52 AM
  2. Gauges and doubts regarding game apps on j2me
    By comp_student in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: July 5th, 2012, 03:20 AM
  3. Boolean method returning a boolean value
    By Deprogrammer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 21st, 2010, 10:56 AM
  4. Doubts Over Base Class
    By rakesh86shankar in forum Object Oriented Programming
    Replies: 1
    Last Post: September 29th, 2010, 09:04 AM
  5. Urgent Doubts
    By shilpareddy553 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 27th, 2010, 02:26 AM