Hey, I'm new to Java and I have an assignment where I have to convert a temperature in Celsius to Fahrenheit, easy enough. The thing is I need to find a way to remove the .0 if it is a whole number

I tried the following way but it doesn't work, 32 will print out as 32.0.

I got it to work using 4 if statements but I want to find a shorter way to do it.

import java.util.Scanner;

public class Convert

{

public static void main(String[] args)

{

Scanner keyboard = new Scanner(System.in);

double celsius;

double fahrenheit;

//Get user input

System.out.print("Enter a temperature in celsius ");

celsius = keyboard.nextDouble();

//convert to fahrenheit

fahrenheit = (celsius*9)/5+32;

//check for decimal 0

double temp1 = celsius;

temp1 *= 10;

temp1 %= 10;

if (temp1 == 0)

celsius = ((int)celsius);

double temp2 = fahrenheit;

temp2 *= 10;

temp2 %= 10;

if (temp2 == 0)

fahrenheit = ((int)fahrenheit);

else

fahrenheit = fahrenheit;

System.out.println("\n" + celsius + " degrees Celsius is equivilant to " + fahrenheit + " degrees Fahrenheit");

}

}