Sunday, 5 November 2017

java programm convert seconds into hour mintue and seconds



Problem 03:
Write a program that ask the user to enter the time in seconds and convert into hour minute and seconds..
Description:
By using the remainder operator 
Solution
import java.util.*;
public class Message {
 public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long  s,h,m;
    System.out.println("Enter the time in seconds");
    s=in.nextInt();
    h=s/3600;
    s%=3600;
    m=s/60;
    s%=60;
   System.out.println("The  time is  ="+h +" HH      "+m+" MM     "+s+" SS");
 }
}

Output
                    

java energ into mass program



Write  program that ask from the user to enter the mass and radius and display the  result of m the result in floating point.
Description:
By writing the equation as     m*r*r              display the result
Solution
public class Message {
 public static void main(String[] args) {
   float mass=99.9f,radius= 44.4f;
   System.out.println("The  result is ="+(mass*radius*radius));
 }
}

Output:
          196938.88

java program



Problem 01:
 Write a program that display the result of 23.5.
Description:
Using  predefine methed Math.pow(2,3.5)
Solution
public class Message {
 public static void main(String[] args) {
  
   System.out.println("The result is "+Math.pow(2, 3.5));
 }
}
Output:
11.3339
                 

java program that convert tempreatur into fahernhite



Problem 05:
Write a program that reads a Celsius degree in
a double value from the console, then converts it to Fahrenheit and displays the
result. The formula for the conversion is as follows:
fahrenheit = (9 / 5) * celsius + 32
Hint: In Java, 9 / 5 is 1, but 9.0 / 5 is 1.8.
Here is a sample run:
learn from examples
document analysis and design


Description:
Hint: In Java, 9 / 5 is 1, but 9.0 / 5 is 1.8.
Here is a sample run:
learn from examples
document analysis and design

Solution
 import java.util.*;
public class Message {
 public static void main(String[] args) {
   
Scanner Input = new Scanner(System.in);
System.out.println("Enter the temperature in Degree celcius");
float cel = Input.nextFloat();

   System.out.println("The temperatur in fahernhite is "+((9.0/5)*cel+32));
}
}

Output