Write a program that accepts two numeric values from the user and displays all integers between these values. Your program will

Accept a starting value
Accept an ending value
Display all the integers (inclusive) between those two values. Your program should count up or down (depending on whether the starting value is greater or less than the ending value)

Here's what I wrote:

String firstString = a.getText();
double a = Double.parseDouble(firstString);

String secondString = b.getText();
double b = Double.parseDouble(secondString);

if(b-a >=1){
for (i=a; i<= b; i++){

outputArea.setText("The value is "+ i);

The issue is that instead of displaying all the numbers between 2 numbers that user enters, my visual calculator only shows the bigger number in a screen. Please help!

1 answer

Ignoring the syntax error of the missing close brace,

all you do is set the text to the latest string displayed. All the other strings are replaced. You need to append a new line for each value of i, not just do a clean reset of the text area each time.