Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. package edu.wit.cs.comp1000;
  2.  
  3. import java.util.Scanner;
  4.  
  5. // @author: Jim Garrison
  6. public class PA1b {
  7.  
  8. // TODO: Converts inches provided into yards, feet, and remaining inches, respectively.
  9. public static void main(String[] args) {
  10. Scanner input = new Scanner(System.in);
  11.  
  12. System.out.print("Enter number of inches: ");
  13. int inputInches = input.nextInt();
  14. int yard = 36;
  15. int feet = 12;
  16. int finalYards;
  17. int finalFeet;
  18. int remainingInches;
  19.  
  20. finalYards = inputInches / yard;
  21. inputInches = inputInches - (36 * finalYards);
  22. finalFeet = inputInches / feet;
  23. inputInches = inputInches - (12 * finalFeet);
  24. remainingInches = inputInches;
  25.  
  26. System.out.printf("Yards: %d%n", finalYards);
  27. System.out.printf("Feet: %d%n", finalFeet);
  28. System.out.printf("Inches: %d%n", remainingInches);
  29.  
  30. input.close();
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement