I do Java as part of my programming at college, and some of the tasks I've done I've needed to do at home. I run a 2017 MacBook Pro, but at college we have a HP desktop of some kind, and what I've had happen is if I've used a "£" symbol in my codes on the PC and then ran them on my Mac, the compiling brings back an error.
This is the code where I use the symbol:
public void depositMoney()
{
int request = 0;
System.out.println("How much money do you wish to deposit into your RunshawPay account? Min: £2.50 / Max: £360.00");
System.out.print("£");
String depositRequest = inputScanner.nextLine();
try//type check
{
request = Integer.parseInt(depositRequest);
if (request <2.50 || request >360)
{
System.out.println("Number cannot be outside of range. [range]");
}
else
{
System.out.print("Amount is ok!");
}
}
catch (NumberFormatException ex)
{
System.out.println("Input needs to be integer. [type]");
}
}
This is the error I recieve on the Terminal:
ModularValidation2.java:60: error: unmappable character (0xA3) for encoding UTF-8
System.out.println("How much money do you wish to deposit into your RunshawPay account? Min: �2.50 / Max: �360.00");
ModularValidation2.java:60: error: unmappable character (0xA3) for encoding UTF-8
System.out.println("How much money do you wish to deposit into your RunshawPay account? Min: �2.50 / Max: �360.00");
ModularValidation2.java:61: error: unmappable character (0xA3) for encoding UTF-8
System.out.print("�");
I have showed this error to my tutor, who was as stumbled by it as me. I've tried to replace the characters by pressing the key into the editor (I'm using Sublime). Does anyone have any idea as to why this is happening and what a solution may be? Many thanks!