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: PLEASE HELP ME WITH MY COLLEGE LAB!

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PLEASE HELP ME WITH MY COLLEGE LAB!

    Basically im writing a java code for class which we do once a week but this week i am completely stumped. I cant seem to completely understand the looping process and would really appreciate any kind of help i can get one where and how to insert it. The following is my task and what i have so far:

    A hotels occupancy rate is calculated as follows:

    Occupancy rate = number of rooms occupied / total number of rooms

    Write a program that calculates the occupancy rate for each floor of a hotel. The program should start by asking for the number of floors in the hotel.
    A loop should then iterate once for each floor. During each iteration, the loop should ask the user for the number of rooms on the floor and the number of
    them that are occupied. After all the iterations, the program should display the number of rooms the hotel has, the number of them that are occupied,
    the number that are vacant, and the occupancy rate for the hotel.



    {// begin class
    public static void main (String[]args)
    {// begin method
    String inputString; //for reading input
    double floors; //number of floors in the hotel
    double rooms; //number of rooms on the floor
    double occupied; //number of rooms occupied
    int number; // loop control variable

    // Create a DecimalFormat object.
    DecimalFormat formatter = new DecimalFormat("#0.00");

    //get number of floors in hotel
    inputString = JOptionPane.showInputDialog(null, "What is the number of floors in the hotel?");

    //convert input to double
    floors = Double.parseDouble(inputString);

    //get number of rooms on the floor
    inputString = JOptionPane.showInputDialog(null, "What is the number of rooms on the floor?");

    //convert input to double
    rooms = Double.parseDouble(inputString);

    //get the number of rooms that are occupied
    inputString = JOptionPane.showInputDialog(null, "What is the number of rooms that are occupied?");

    //convert input to double
    occupied = Double.parseDouble(inputString);
    }

    //end the program
    System.exit(0);
    }//end method
    }//endclass


    Any help at all is greatly appreciated, thank you!


  2. #2
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: PLEASE HELP ME WITH MY COLLEGE LAB!

    buuumpppppppp

  3. #3
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default Re: PLEASE HELP ME WITH MY COLLEGE LAB!

    3 Things:
    • Bumping threads makes it look like someone has already replied and is actually quite likely to make less people reply. Also, it makes it seem like you think your time is more valuable than everyone else's here on the forums. Most likely, 75% of the posts here are 'urgent'. If you want immediate help you can pay for it, I think the average is $2.50 a minute over at LivePerson.
    • Highlight your code with bb code.
    • Please post your specific problem, that makes it more likely for people to be able to give relevant information. You just posted some code and the assignment. Are you getting an error? Are you not sure how to create loops? Specific Questions get Specific Answers.
    Last edited by Tjstretch; October 29th, 2011 at 12:02 PM.

  4. #4
    Junior Member
    Join Date
    Jun 2011
    Location
    Delhi
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: PLEASE HELP ME WITH MY COLLEGE LAB!

    ...edited by moderator
    Last edited by copeg; October 29th, 2011 at 01:59 PM.

  5. #5
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default Re: PLEASE HELP ME WITH MY COLLEGE LAB!

    Sigh, if you didn't read my last post, code tags save everyone a LOT of trouble. I do not generally read code that isn't in tags, but because your post just contains code, I'm willing to bet it's a full solution. You should read: The Problem with Spoon-feeding

  6. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: PLEASE HELP ME WITH MY COLLEGE LAB!

    Saurabh Mittal, please read the forum rules and the link provided by Tjstretch. Your post has been edited.

  7. #7
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: PLEASE HELP ME WITH MY COLLEGE LAB!

    Thats a stupid forum rule. How are you supposed to learn if u cant see exactly what the code looks like? Its not a math problem i can solve for myself with the right formula. Its more like a science question where i need the exact answer and the next time someone asks me the question i will know the answer. Whatever, i will repost then if it makes you happy.

  8. #8
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: PLEASE HELP ME WITH MY COLLEGE LAB!

    Quote Originally Posted by crsoccerplayer6 View Post
    Thats a stupid forum rule. How are you supposed to learn if u cant see exactly what the code looks like? Its not a math problem i can solve for myself with the right formula. Its more like a science question where i need the exact answer and the next time someone asks me the question i will know the answer. Whatever, i will repost then if it makes you happy.
    Programming isn't about seeing the solution, its about creating the solution. Having a solution handed to you - which the above post accomplished with no description about what and why - robs you of the process of creating solutions, the thought that goes into it, the learning that you achieve along the way, and the feeling of accomplishment when you reach your goal. Further, these forums are not about helping people cheat - they are about helping one learn (whatever your goal is here, we get enough visitors interested in academic dishonestly to implement particular rules). If you are willing to be guided through the learning process then I encourage you to read the getting help link in my signature and this article, post a specific question, and help us help you.
    Last edited by copeg; October 29th, 2011 at 04:12 PM.

Similar Threads

  1. College Assignment please help
    By The Lost Plot in forum Collections and Generics
    Replies: 7
    Last Post: March 13th, 2012, 09:27 AM
  2. College Course-Array
    By samuel17 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 14th, 2010, 10:29 PM
  3. New to Programming, Starting college for computer engineering
    By TheBLC84 in forum Java Theory & Questions
    Replies: 1
    Last Post: September 17th, 2010, 04:06 AM