today I'll give an example of color assign a colorto a number when you are developing a program that has the need to present positive or negative numbers just think how to makethese numbers have something visual to identify them and I had thisproblem when he was developing a data management system, forexample in a month was July and the following month he was 8 thenwent up a point and wanted this one point is shown in green andsome data presented if negative data that shows up in red. go towork. First let's make a method that returns the desired value.
public String Comparação(){} //comparing number data
Let's go inside the body of logic, as I said it is a method of strings, I'll have to do the conversion with parseInt. I'll put something visual, such as JOptionPane.
String Numero = JOptionPane.showInputDialog("Digite um número");
int numero = Interger.parseInt(Numero);
And I keep doing logic with the if.
if(numero < 0)
{
Numero = "< html >< font color=\"red\" >" + Numero + "< / font >< / html>";
}else{
Numero = "< html>< font color=\"green\">" + Numero + "< / font>< / html>";
}
See that I needed to put the html tag to help. And in the end I put the return Number;
Ready now can test.
Until the next post.
Nenhum comentário:
Postar um comentário