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!
Re: PLEASE HELP ME WITH MY COLLEGE LAB!
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.
Re: PLEASE HELP ME WITH MY COLLEGE LAB!
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
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.
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.
Re: PLEASE HELP ME WITH MY COLLEGE LAB!
Quote:
Originally Posted by
crsoccerplayer6
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.