Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main
- {
- public static void main(String[]args)
- {
- int NumM, NumK, Num;
- boolean IsCorrect;
- NumM = 0;
- Num = 4;
- NumK = 0;
- Scanner in = new Scanner(System.in);
- System.out.print("Given an integer m > 10. Find the largest integer k for
- which 4^k < m.\n");
- System.out.print("Enter an integer (>10): ");
- do
- {
- IsCorrect = false;
- try {
- NumM = Integer.parseInt(in.next());
- }
- catch (NumberFormatException e) {
- System.out.print("Incorrect value. Enter the number: ");
- IsCorrect = true;
- }
- if ((!IsCorrect) && (NumM < 10))
- {
- System.out.print("Incorrect value. Enter the number: ");
- IsCorrect = true;
- }
- } while (IsCorrect);
- in.close();
- while (Num < NumM) {
- Num = Num * 4;
- NumK++;
- }
- System.out.print(NumK);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement