Hi,
I need ur help regarding to do this program in java....i need to do program where user can input any number n this program will count until reach 100...if reach then the program will print out :---bla bla bla.....if not user can keep input the integer..how to to?...i'm dizzy right now...

Here the progress that i done :-

import java.io.*;                 //import the java.io package 

class calc 
{
     public static void main ( String [] args ) throws IOException     //throw any exceptions
     {
          BufferedReader stdin =  new BufferedReader(new InputStreamReader( System.in ));

           
           System.out.print( " Please enter number (integer) =  " );
            String input   =   stdin.readLine();             //get integer a
            int a    =   Integer.parseInt( input );
          
           
           
          
          
            
      //      int count = 1;
        //  while (count  < 100) {
          //     System.out.println("Count is: " + count);
            //   count++;
		
}
     


         
}                                                          // end calc

Come out of your dizziness and think and code something solid. So far you have simply taken an input. You have not done anything about the logic so far.

Also, the question itself is a bit gibberish. Please be more specific about what you want to do.

Ok ...what i'm want to do is....the user can input any value but must be below than 100....let say user input no :1,after that that user still can input value until reach 100...that mean 1 + ...+ ...+....+..= < 100...if reach 100 the the program will tell " U enter more then 100'///.....can u help me please...i noob in java..tq

use your while statement,1) place your question to promt the user for a input inside the while statement, 2) you need a conditional statement inside your while aswell i.e an "if" statement to ensure that the user has entered a number below 100, if the condition is met you sum the entered number with the previous ones entered(you'll probably need an extra int variable to hold the summed value).3) if the while end tel the user that he passed 100 or whatever you want to. Use what you've got thus far, your not that far off from a solution.

krefie

Edited 6 Years Ago by Krefie: n/a

im newbie in programming too.but i wanna share my idea.what i understand is,user key in the list of numbers which the sum of the number must not equal to 100.isnt it?

if true,i think u should create an array for int a for list of numbers.
then use while like previous forumer said.
then check the sum of the input (mayb can use if) <100.
mayb can use sum=a+a

any comment about my idea?

why not initialize a integer before the while say

int sum = 0;

then in the while just keep adding to the sum

sum = sum + newInput;

i dont really see why there needs to be an array? or i'm missing something?

Krefie

Krefie is right.
Using an array for such a simple task is a bit overkill.

@Kerek2:
try out what Krefie suggested and write some code, taking Krefie's hint. Unless you code (a lot) yourself you'll always remain a 'noob'.

Good Luck.

mmm...still stuck ..i manage to get sum but just display sum when reach 100

what i need is the output will display all the input then sum it like this :-

(1+2=3+4=7+3=10 - break reach 100)

can anyone guid me more pls

This article has been dead for over six months. Start a new discussion instead.