Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- A program that reads in an angle of any size (positive or negative),
- normalizes it, and prints it out.
- For example, the input of 380 should print 20,
- and the input of -30 should return 330.
- All variables should be of type int.
- */
- public class Angles
- {
- public static void main (String[] args)
- {
- // Display prompt for degrees of angle
- System.out.println("Please enter the number of degrees of angle: ");
- // Read angle in degrees
- Scanner in = new Scanner(System.in);
- int angle = in.nextInt();
- // Compute normalized value of angle
- int normalized = angle;
- while(normalized < 0 || normalized > 359)
- {
- if(normalized < 0)
- {
- normalized += 360;
- }
- else
- {
- normalized -= 360;
- }
- }
- // Print out the normalized value of the angle
- System.out.println(normalized);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement