Академический Документы
Профессиональный Документы
Культура Документы
import java.util.Arrays;
import java.util.Scanner;
case "2":
System.out.print("Type another string: ");
String stringForPosition = sc.nextLine();
int[] position = storePosition(stringForPosition, 'n');
System.out.println("\'n\' in string \"" + stringForPosition +
"\" has " + Arrays.toString(position) + " positions");
break;
case "3":
try {
System.out.print("Type first number: ");
int first = Integer.parseInt(sc.nextLine());
System.out.print("Type second number: ");
int second = Integer.parseInt(sc.nextLine());
long pow = myPow(first, second);
System.out.println(first + " in power " + second + " = " +
pow);
}
catch(NumberFormatException e){
System.out.println(e.getMessage() + " is wrong number format");
}
break;
case "4":
System.out.println("Type a string for statistics: ");
String statistics = sc.nextLine();
printStatistic(statistics);
break;
case "exit":
case "quit":
sc.close();
return;
default:
System.out.println("Wrong command");
break;
}
}
}