Project Name : {{this.currentFile.name}}
Your Code ...
import java.util.Scanner; public class AnalogMain { public static float m=0,h=0; public static float minuteAngle=0, hourAngle=0, angleBtwnHands=0; @SuppressWarnings("resource") public static void main(String[] args) { try{ Scanner in = new Scanner(System.in); System.out.println("Enter the hour"); h = Float.parseFloat(in.nextLine()); System.out.println("Enter the minute"); m = Float.parseFloat(in.nextLine()); getAngleBetween(h,m); }catch(Exception e){ System.out.println("Error while processing values from the user : "+e); } } public static void getAngleBetween(float inputHour, float inputMinute){ if(isValidInputs(inputHour,inputMinute)){ if (inputHour == 12) inputHour = 0; if (inputMinute == 60) inputMinute = 0; minuteAngle=getMinuteAngle(inputMinute); hourAngle=getHourAngle(inputHour,inputMinute); angleBtwnHands=Math.abs(hourAngle-minuteAngle); System.out.println("\nAngle Between hour and minute hand is : "+angleBtwnHands+" Degree"); }else{ System.out.println("Invalid Inputs"); } } public static boolean isValidInputs(float inputHour, float inputMinute){ boolean result=true; if (inputHour < 0 ||inputMinute<0 ||inputHour>12 || inputMinute > 60){ result=false; System.out.println("Invalid Input "); } return result; } public static float getMinuteAngle(float inputMinute){ float outputMinuteAngle=0; outputMinuteAngle=(inputMinute*6); System.out.println("\n"+"Minute Hand Angle :"+outputMinuteAngle+" Degree"); return outputMinuteAngle; } public static float getHourAngle(float inputHour,float inputMinute){ float outputHourAngle=0; outputHourAngle=(float)((inputHour*60+inputMinute)*0.5); System.out.println("\n"+"Hour Hand Angle : "+outputHourAngle+" Degree"); return outputHourAngle; } }
CommandLine Arguments ...
Stdin Inputs...
Interactive mode :

Focus View:

Version :
External Libraries ...
  • {{ lib }}
Please Login to use this function
Share URL
CPU Time: {{this.cpuTime}} sec(s), Memory: {{this.memory}} kilobyte(s)
compiled and executed in {{this.executionTime}} sec(s)
Please enter all values - GroupID, ArtifactID and Version
Note: you can search maven artifact details in http://search.maven.org/ or http://mvnrepository.com/
Trying to save your file, Please wait...

My {{this.language}} Projects

Loading, Please wait...
File Deleted Successfully
Unable to Delete, please try again later or contact JDoodle support

Are you sure, you want to delete this file?

Recent {{this.language}} Projects

{{moment(option.executedAt).format("MMMM Do YYYY, h:mm:ss a")}}
{{this.setLanguage("java", "JDK 1.8.0_66, JDK 9.0.1, JDK 10.0.1",".java",false, 2)}}
{{this.setShared("", "","","jdoodle.com/a/FhU","https://www.jdoodle.com/embed/v0/FhU")}}
Your valuable inputs will help us improve this site
please give your comments. Thanks.
Which language would you like to see next in JDoodle?
Thanks for your Input!
{{this.surveyForm.comment}} is already available at {{this.surveyForm.existingPath}}
For direct response, please include your email id in the comment
or email to jdoodle@nutpan.com
Thanks for your Input!

Sign in

New to JDoodle ? -
JDoodle is trying to signin you in, Please wait...


Thanks for registering!!!
We have sent you an email for confirmation.
Before login, Please check your email to complete the registration!
Already Have an Account ? -
We recommend
or you can register with your email below
{{ message }}
JDoodle is creating an account for you, Please wait...
By registering, you agree to the Terms of Service

Forgot Password


Please check your email for password reset link.

JDoodle is checking your details, Please wait...

Unlock Account


Please check your email for unlock link.

JDoodle is checking your details, Please wait...

Change Password

Password Successfully Changed


Change Display Name


Display Name Successfully Updated

Welcome to JDoodle

app loading now, please wait...