Westonci.ca is the best place to get answers to your questions, provided by a community of experienced and knowledgeable experts. Experience the convenience of finding accurate answers to your questions from knowledgeable experts on our platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.

How can I get multiple user inputs in Java ? I want to be able to use it for subtraction, addition,division and multiplication.For example it should run like
How many numbers do you want to subtract?
4
Enter 4 numbers:
1
2
3
4
result:-8


Sagot :

nunoz
You can do something like this :

Scanner sc = new Scanner(System.in);
int[] nums = new int[4];

for(int i = 0; i < nums.length; i++) {
System.out.println("Enter next number: ");
nums[i] = sc.nextInt();
Thank you for visiting our platform. We hope you found the answers you were looking for. Come back anytime you need more information. We hope our answers were useful. Return anytime for more information and answers to any other questions you have. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.