473,396 Members | 1,780 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,396 software developers and data experts.

please help i am a noob to java

ok my brain is about to explode i do not get this at all can someone please help me out.


Write a switch statement you may combine the less than and greater than into one statement.

X is less than 1
X is 1
X is 2, 3 or 4
X is greater than 4


i know how to write a switch statement but not with less than and greater signs can someone help in the easiest way possible to solve this.


also how would i write a while loop which counts from 0 to -0.02 in steps of -0.01.???????
the code i have for the while loop is
Expand|Select|Wrap|Line Numbers
  1. public class whileloop
  2. {
  3.    public static void main(String[] args)
  4.    {
  5.        int number = 0;
  6.        double max = -0.02;
  7.  
  8.        while (number <= max)
  9.        {
  10.            System.out.println("max");
  11.            number--;
  12.        }
  13.  
  14.        System.out.println(max);
  15.     }    
  16. }
  17.  
PLEASE HELP
Mar 2 '09 #1
2 1322
r035198x
13,262 8TB
For switch part, let's see your attempt first.

For the while part, you are printing the String "max" not the value of number that you should be printing. Also when you do number--; that is just the same as doing number = number -1;
If number starts at zero and you do number = number - 1; as your first step then what do you get? Is that what you want?
Mar 3 '09 #2
JosAH
11,448 Expert 8TB
This question was cross posted in Sun's Java forum. There's no need to answer it here as well.

kind regards,

Jos (moderator)
Mar 3 '09 #3

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

Similar topics

3
by: digitalsubjunctive | last post by:
Hey, I just started on Python and have a few questions I couldn't find answers to on the Python site or it's tutorial. 1. I notice a few "compiled python" files (indicated by reddish snake...
14
by: Olumide | last post by:
In the following C++ class, MyClass{ // Members } From which I create two objects (using the default constructor), (1) MyClass *object1 = new MyClass(); // Stack (2) MyClass object2 =...
11
by: Brian Blazer | last post by:
OK, I have a very simple class here: class Student: """Defines the student class""" def __init__(self, lName, fName, mi): self.lName = lName self.fName = fName self.mi = mi
29
by: mike_wilson1333 | last post by:
I would like to generate every unique combination of numbers 1-5 in a 5 digit number and follow each combo with a newline. So i'm looking at generating combinations such as: (12345) , (12235),...
5
by: Hydrogenfussion | last post by:
Hello and thank you for reading this. I have just started to learn C++ from www.cprogramming.com,its a great site! But i do not understand some of the terms. I am using Dev-C++. Can you tell me...
2
gekko3558
by: gekko3558 | last post by:
I have not worked with java in a while, and all i'm trying to do is read these numbers from a file into a 2D array. This is my code import java.io.*; import java.util.*; public class...
62
by: vubaboota | last post by:
I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C Q1: Write a program using malloc function. In which you take input from user and allocate memory equal to square of this number. Which...
3
by: nooblet | last post by:
i am trying to learn how to write a stand alone java application where i can access online java game such as runescape etc. but not actually open up a browser but still access the sever to log in. im...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...

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.