Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package test;
  7.  
  8. import java.util.InputMismatchException;
  9. import java.util.Scanner;
  10.  
  11. /**
  12. *
  13. * @author Adam
  14. */
  15. public class Test
  16. {
  17.  
  18. static Scanner keyboard = new Scanner(System.in);
  19.  
  20. /**
  21. * @param args the command line arguments
  22. */
  23. public static void main(String[] args)
  24. {
  25. getData();
  26. }
  27.  
  28. public static int getData()
  29. {
  30.  
  31. try
  32. {
  33. System.out.println("How much data does the customer use per month?(MB)");
  34.  
  35. int dataIn = keyboard.nextInt();
  36. int dataValue = 0;
  37.  
  38. if (dataIn <= 1000)
  39. {
  40. dataValue = 1;
  41. }
  42. else if (dataIn <= 4000)
  43. {
  44. dataValue = 2;
  45. }
  46. else if (dataIn <= 8000)
  47. {
  48. dataValue = 3;
  49. }
  50. else if (dataIn > 8000)
  51. {
  52. dataValue = 4;
  53. }
  54. return dataValue;
  55. }
  56. catch (InputMismatchException ie)
  57. {
  58. System.out.println("Incorrect format for ");
  59. dataIn = keyboard.nextInt();
  60. return getData();
  61. }
  62.  
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement