Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ConvertFromBase7ToDecimal {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int n = input.nextInt();
- int fromBase = 7;
- int toBase = 10;
- System.out.println(fromBaseToBase(n, fromBase, toBase));
- }
- public static String fromBaseToBase(int number, int fromBase, int toBase){
- String numStr = Integer.toString(number);
- try {
- return Integer.toString(Integer.parseInt(numStr, fromBase), toBase);
- }catch (Exception ex){
- return "Invalid Entry!";
- }
- }
- }
Add Comment
Please, Sign In to add comment