When you declare a variable inside a function, such as in your setAmount, it only exists for as long as that function is executing; it only exists between the { and }. That's why you're unable to reference it later in the second function, as it no longer exists. Essentially, what you're doing is setting it, and then getting rid of it right away, through no effort on your code, but simply through the way memory is allocated and used in programs.
The way to get around this would be to use a "global" as you've said, or to pass it back after you set it, and put it into another variable, which you then send to your displayInvoice function. The last method requires that the setAmount and displayInvoice are part of a larger function themselves, and the intermediary variable is declared inside it. Over all, a "global" as you've said, is the easiest and probably best solution given what you've explained.
Unworking Example:
main() {
int amount = 0;
amount = setAmount(5);
displayInvoice(amount);
}
In doing so though, you may as well forgo the setAmount function, as you can see it's fairly redundant. Keeping set amount, you'd need to change it to
Public int setAmount(int anyAmount)