Advertisement
irishstorm

modConverter.java

Dec 12th, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /*  irishstorm
  4.     13/12/2015
  5.     Built this because i'm really bad and lazy when it comes to maths, Built with hill 2 cipers in mind.            
  6. */
  7. public class modConverter
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner input = new Scanner(System.in);
  12.         int option = 0,
  13.             result = 0,
  14.             mod = 26;
  15.         do
  16.         {  
  17.             System.out.println("******** Modulo Converter ********");
  18.             System.out.println("1.\tEnter a number to convert ");
  19.             System.out.println("2.\tChange Mod (26 by Default) ");
  20.             System.out.println("3.\tExit Program ");
  21.             option = input.nextInt();
  22.  
  23.             switch(option)
  24.             {
  25.                 case 1:
  26.                     System.out.print("Enter a number : ");
  27.                     int number = input.nextInt();
  28.  
  29.                     result = number % mod;
  30.            
  31.                     if (result < 0)
  32.                         result = result + mod;
  33.  
  34.                     System.out.print(number + " mod " + mod + " is " + result + "\n\n");
  35.                 break;
  36.  
  37.                 case 2:
  38.                     System.out.print("Enter a mod : ");
  39.                     mod = input.nextInt();
  40.                     System.out.print("\n");
  41.                 break;
  42.  
  43.                 case 3:
  44.                     System.out.print("Exiting Program...\n\n");
  45.                     System.exit(0);
  46.                 break;
  47.  
  48.                 default:
  49.                     System.out.print("Invalid Option - Please select an option 1 - 3.\n\n");
  50.             }
  51.         }
  52.         while(option != 100000);
  53.     }  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement