473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How to use loop in Java?

13
hi there,
i would like to know the simplest way using loop to solve the situation below:

Room allocation is performed on a semester basis. The college follows a two semester system i.e. there are 2 semesters in each academic year. Before the start of each semester, students may apply for hostel rooms for the coming semester. All rooms in the hostel are for single occupancy and are of the same type. There are 4 floors in the hostel with 8 rooms on each floor. The floor number is from 1 to 4 and the room numbers on each floor are from 1 to 8.

Many thanks.
please help me out...i'm new to Java !!!
Jun 27 '07 #1
3 4834
r035198x
13,262 8TB
hi there,
i would like to know the simplest way using loop to solve the situation below:

Room allocation is performed on a semester basis. The college follows a two semester system i.e. there are 2 semesters in each academic year. Before the start of each semester, students may apply for hostel rooms for the coming semester. All rooms in the hostel are for single occupancy and are of the same type. There are 4 floors in the hostel with 8 rooms on each floor. The floor number is from 1 to 4 and the room numbers on each floor are from 1 to 8.

Many thanks.
please help me out...i'm new to Java !!!
I don't get what the problem is. Do you want to write a program that allows students to book these rooms? Please respond also with what you have done so far.
Jun 27 '07 #2
praveen2gupta
201 100+
Java is suppoerted by Two types of Loops

1. For Loop

for(declaration; condition; increment;)

Example

for(int room=0; room<=8; room++)
{
// body of the loop
}


2. While Loop

you can solve your problem with for loop.
Jun 28 '07 #3
r035198x
13,262 8TB
Java is suppoerted by Two types of Loops

1. For Loop

for(declaration; condition; increment;)

Example

for(int room=0; room<=8; room++)
{
// body of the loop
}


2. While Loop

you can solve your problem with for loop.
The body of your for loop will be entered 9 times.
There's also the do while loop.
Jun 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: JS | last post by:
#include <stdio.h> main(){ int c, i, nwhite, nother; int ndigit; nwhite = nother = 0; for (i = 0; i < 10; ++i)
17
by: Allerdyce.John | last post by:
Hi, I am trying to compare the amount of work between using STL algorithm VS a plain Java loop. Let's say the class Rect has 2 attributes: area, and areaPerCent. In Java, I just write a...
73
by: Claudio Grondi | last post by:
In the process of learning about some deeper details of Python I am curious if it is possible to write a 'prefix' code assigning to a and b something special, so, that Python gets trapped in an...
5
by: hprYeV | last post by:
I have done a reasonable amount of programming in C++, but the other day I was talking to someone after a lecture in a course on Java who said that they had not been used to the syntax of the Java...
5
by: oaklander | last post by:
I have this JSP where I have alot of fields with conditions. I would like to make it more efficient and use a for loop. Here is an example (showing 2 fields for example only): <%@ page...
4
by: chellemybelle | last post by:
Hello, I basically have made a little cheezy slideshow and would like to add captions to each pic as it loops through. I've tried everything I can think of. I'm assuming I might need to use an...
1
by: saytri | last post by:
I have a problem with this code. I'm, doing a quiz, and the questions are stored in a binary file. My problem is how am i going to compare the answers entered by the user to the correct answers. The...
12
by: beatjunkie27 | last post by:
I am working on a class assignment called Pennies for Pay the object of the program is to receive input for number of days worked. This should be > 0 and <= 40. An example output is below and...
1
by: JavaJon | last post by:
Hello, I'm Jon. I've recently picked up Java after using a "gimmick" programming language called GML ( Game Maker Language ). I've read a lot of tutorials and even a Java for Dummies *.pdf book....
4
by: crochunter | last post by:
Hi, I want to read values from a text files from specified fields and use them as values to fill my methods inside the paintComponent() method. I am using for loop to do that but not able to do it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.