Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package test;
- import java.util.InputMismatchException;
- import java.util.Scanner;
- /**
- *
- * @author Adam
- */
- public class Test
- {
- static Scanner keyboard = new Scanner(System.in);
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args)
- {
- getData();
- }
- public static int getData()
- {
- try
- {
- System.out.println("How much data does the customer use per month?(MB)");
- int dataIn = keyboard.nextInt();
- int dataValue = 0;
- if (dataIn <= 1000)
- {
- dataValue = 1;
- }
- else if (dataIn <= 4000)
- {
- dataValue = 2;
- }
- else if (dataIn <= 8000)
- {
- dataValue = 3;
- }
- else if (dataIn > 8000)
- {
- dataValue = 4;
- }
- return dataValue;
- }
- catch (InputMismatchException ie)
- {
- System.out.println("Incorrect format for ");
- dataIn = keyboard.nextInt();
- return getData();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement