python to java converter

Solutions on MaxInterview for python to java converter by the best coders in the world

showing results for - "python to java converter"
Alessandra
10 Apr 2016
1print('jjj');
Jebediah
30 Jun 2017
1import sys
2import math
3
4
5width = int(input())
6height = int(input())
7players = int(input())
8
9class Player:
10    def __init__(self, x, y):
11        self.x = x
12        self.y = y
13
14DIR = {'UP' : 'C', 'RIGHT' : 'A', 'DOWN' : 'D', 'LEFT' : 'E', 'STAY' : 'B'}
15
16grid = [['?' for x in range(width)] for y in range(height)]
17enemies = [Player(-1,-1) for e in range(players-1)]
18player = Player(-1,-1)
19
20def enemyAtPos(x, y):
21    for e in enemies:
22        if x == e.x and y == e.y:
23            return True
24    return False
25def getPossibleMoves(x, y):
26    possibleMoves = []
27    if grid[(y-1)%height][x] != '#':
28        if not enemyAtPos(x, y-1) and not enemyAtPos(x, y-2) and not enemyAtPos(x-1, y-1) and not enemyAtPos(x+1, y-1):
29            possibleMoves.append([x, (y-1)%height])
30    if grid[y][(x+1)%width] != '#':
31        if not enemyAtPos(x+1, y) and not enemyAtPos(x+2, y) and not enemyAtPos(x+1, y-1) and not enemyAtPos(x+1, y+1):
32            possibleMoves.append([(x+1)%width, y])
33    if grid[(y+1)%height][x] != '#':
34        if not enemyAtPos(x, y+1) and not enemyAtPos(x, y+2) and not enemyAtPos(x-1, y+1) and not enemyAtPos(x+1, y+1):
35            possibleMoves.append([x, (y+1)%height])
36    if grid[y][(x-1)%width] != '#':
37        if not enemyAtPos(x-1, y) and not enemyAtPos(x-2, y) and not enemyAtPos(x-1, y-1) and not enemyAtPos(x-1, y+1):
38            possibleMoves.append([(x-1)%width, y])
39
40    return possibleMoves
41
Fabian
01 Apr 2018
1print("1. Addition \n")
2print("2. Subtraction \n")
3print("3. Multiplication \n")
4print("4. Division \n")
5menu = input("Please Insert Menu \n")
Dante
10 Aug 2017
1def SeatingStudents(arr):
2
3  K = arr[0]
4  occupied = arr[1:]
5
6  rows = int(K/2)
7
8  seats = []
9  x = 0
10  
11  for i in range(rows):
12    seats.append([])
13    for j in range(2):
14      if((x+1) in occupied):
15        full_seat = True
16      else:
17        full_seat = False
18      seats[i].append(str(full_seat))
19      x+=1
20
21  seating = 0
22  for i in range(rows-1):
23    if((seats[i][0] == str(False)) and (seats[i][1] == str(False))):
24      seating+=1
25
26    if((seats[i][0] == str(False)) and (seats[i+1][0] == str(False))):
27      seating+=1
28
29    if((seats[i][1] == str(False)) and (seats[i + 1][1] == str(False))):
30      seating+=1
31  
32  if((seats[rows - 1][0] == str(False)) and (seats[rows - 1][1] == str(False))):
33    seating+=1
34  return seating
35
36 
37print(SeatingStudents([12, 2, 6, 7, 11]))
Paula
01 Apr 2016
1a-int(input())
2
31=list (map(int,input().split()))
4
51. sort()
6
7b-max(1)
8
9c=min (1)
10
11print (b-c)
Savannah
31 Jun 2019
1Tokenizer
Jasper
01 May 2019
1def getUmbrellas(requirement, sizes):
2    for i in sizes:
3        if i > requirement:
4            pass
5        else:
6            q = requirement / i
7            r = requirement % i
8            if r == 0:
9                return q
10            if r in sizes:
11                return q + 1
12        return -1
Ellery
11 Feb 2019
1print("1- File Duplo\n2- Alcatra\n3- Picanha\n\n")
2tipo = int(input("Digite o tipo: "))
3quantidade = int(input("Digite a quantidade comprada: "))
4resposta = int(input("A compra será realizada com cartao Tabajara? 1p/ SIM - 2p/ NAO: "))
5
6if tipo == 1:
7    nome = "File Duplo"
8    if quantidade <= 5:
9        preco = quantidade * 4.90
10    else:
11        preco = quantidade * 5.80
12        
13if tipo == 2:
14    nome = "Alcatra"
15    if quantidade <= 5:
16        preco = quantidade * 5.90
17    else:
18        preco = quantidade * 6.80
19
20if tipo == 3:
21    nome = "Picanha"
22    if quantidade <= 5:
23        preco = quantidade * 6.90
24    else:
25        preco = quantidade * 7.80
26
27if resposta == 1:
28    r = "SIM"
29
30    desconto = ((preco * 5) /100)
31    total = preco - desconto
32else:
33    r = "NAO"
34    total = preco
35    
36print("\n***************************CUPOM FISCAL**************************************")
37print("* Carne.......................................................... %s " %nome)
38print("* Quantidade..................................................... %d KG " %quantidade)
39print("* Preço......................................................... %2.f R$ " %preco)
40print("* Cartao Tabajara................................................ %s " %r)
41print("* Total com desconto............................................ %2.f R$ " %total)
42print("*************************************************************************
Mathilda
18 Jun 2017
1import javax.swing.*;
2
3public class Exe4{
4	//metodo para calculo de Potencia
5public static int exp(int n1,int n2)   
6{
7	int i=0, total=0;
8	
9	while(i<=n2)
10	{
11			total = n1*n2;	
12			i++;
13	}
14	return total; 
15    
16}
17  
18       
19	//metodo principal
20	public static void main(String args[]){
21		//Declaração de Variáveis
22		int num1, num2;
23		
24		//Entrada de Dados do Usuário
25		num1 = Integer.parseInt(JOptionPane.showInputDialog("Digite um número"));  
26		num2 = Integer.parseInt(JOptionPane.showInputDialog("Digite outro número"));  
27		
28		//Exibição dos dados
29		
30		JOptionPane.showMessageDialog(null, exp(num1,num2));
31		
32	}
33	
34}
35
Mathilde
18 May 2016
1array=list(map(int,input().split(",")))
2array=sorted(array)
3j=[]
4j.append(array[0])
5j.append(array[1])
6for i in range(2,len(array)):
7    if j[i-1]+j[i-2] in array:
8        j.append(j[i-1]+j[i-2])
9    else:
10        break
11print(j)