Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

5.3 / 163) Displaying an integer reversed) Write the following method to display

ID: 3622737 • Letter: 5

Question

5.3 / 163) Displaying an integer reversed) Write the following method to display an integer inverse order: 5.4 / 163) Returning an integer reversed) Write the following method to return an integer reversed: 5.6 / 163) (Displaying patterns) Write a method to display a pattern as follows: 5.8 / 164) (Conversions between Celsius and Fahrenheit) Write a class that contains the following two methods: The formula for the conversion is: fahrenheit = (9.0 / 5) * Celsius + 32 Write a test program that invokes these methods to display the following tables:

Explanation / Answer

please rate - thanks

import java.util.*;
public class reversenumber{
public static void main(String[] args)
{int number;
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
number=in.nextInt();
System.out.println(number+" reversed is "+ reverse(number));
}
public static int reverse(int n)
{int num=0,digit;
while(n!=0)
   {digit=n%10;
    n/=10;
    num=num*10+digit;
    }
return num;
}

}

-----------------------------------------

import java.util.*;
public class reversenumber2{
public static void main(String[] args)
{int number;
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
number=in.nextInt();
System.out.print(number+" reversed is " );
reverse(number);
}

public static void reverse(int n)
{int num=0,digit;
while(n!=0)
   {digit=n%10;
    n/=10;
    num=num*10+digit;
    }
System.out.println(num);
}
}

------------------------------------------

import java.util.*;
public class pattern{
public static void main(String[] args)
{int number;
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
number=in.nextInt();
displayPattern(number);
}

public static void displayPattern(int n)
{int i,j;
for(i=1;i<=n;i++)
    {for(j=n;j>i;j--)
         System.out.print(" ");
    for(j=i;j>=1;j--)
         System.out.print(j+" ");
    System.out.println();
    }
       
}
}

------------------------------------------------

import java.util.*;
public class temp{
public static void main(String[] args)
{double cel=40,fah=120;
System.out.println("Celsius Fahrenheit Fahrenheit Celsius");
while(cel>=0)
   {System.out.printf("%.1f %.1f %.1f %.2f ",cel,celsiusToFahrenheit(cel),fah,fahrenheitToCelsius(fah));
    cel--;
    fah--;
    }

}

public static double celsiusToFahrenheit(double n)
{return (9.0/5.)*n+32;       
}
public static double fahrenheitToCelsius(double n)
{return (5./9.)*(n-32.);       
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote