View RSS Feed

tnd_blazer

Getting user input on how meany times to loop... dunno how

Rate this Entry
by , 06-23-2013 at 12:04 AM (1382 Views)
I have ben trying to get this ... it wont let me change a string to a int. And i dont know of any other way please help
I want the user to be able to put in a number and have the probram loop as meany times as the user puts in.. any ideas?
here is the code i tryed
Java Code:
import java.util.Scanner;
public class ae{
	private static Scanner user_input;	
	public static void main(string[] args){
	System.out.println("How meany times to loop the code");
	user_input = new Scanner( System.in );
	String times;
	times = user_input.next();



	int x = 10;

      while( x < times ) {
         System.out.print("value of x : " + x );
         x++;
         System.out.print("\n");
      }
	}
and i dunno if u can use it this way just wana know if you can.
jancy likes this.

Submit "Getting user input on how meany times to loop... dunno how" to Facebook Submit "Getting user input on how meany times to loop... dunno how" to Digg Submit "Getting user input on how meany times to loop... dunno how" to del.icio.us Submit "Getting user input on how meany times to loop... dunno how" to StumbleUpon Submit "Getting user input on how meany times to loop... dunno how" to Google

Tags: None Add / Edit Tags
Categories
Uncategorized

Comments

  1. tnd_blazer's Avatar
    • |
    • permalink
    someone help me! please?
    jancy likes this.
  2. kattavijay's Avatar
    • |
    • permalink
    Corrected small changes in your code ,compare the code to find the changes .


    import java.util.Scanner;
    public class Ae{
    private static Scanner user_input;
    public static void main(String[] args){
    System.out.println("How meany times to loop the code");
    user_input = new Scanner( System.in );
    int times;
    times = user_input.nextInt();

    int x = 1;

    while( x < times ) {
    System.out.print("value of x : " + x );
    x++;
    System.out.print("\n");
    }
    }
    }
    amol selokar likes this.
  3. allaudin's Avatar
    • |
    • permalink
    what a blog post
    Villa likes this.