Answer to Question #16971 in Action Script | Flash | Flex | ColdFusion for analiza moradas

Question #16971
create a java program that accepts input numbers and continues to do so until a negative entered. It will then display the positive output.
1
Expert's answer
2012-10-24T09:49:44-0400
import java.util.Scanner;




class MyProg{



public static void main(String[] args){




Scanner input = new Scanner(System.in);

int[] arr = new int[100];




int n=0, count=0;

do{

System.out.print("Enter number: ");

n = input.nextInt();

if(n>=0){

arr[count] = n;

count++;

}

}while(n >= 0);

for(int i=0;i<count;i++)

System.out.println(arr[i]);

}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS