convert python to java code example
Example 1: convert python to java
s=input()
l=[]
s1='aeiou'
sum1=0
def snm(sum1):
t=0
while(sum1>0 or t>9):
if(sum1==0):
sum1=t
t=0
t=t+sum1%10
sum1=sum1//10
return t
for i in range(len(s)):
if s[i] in s1:
l.append(i)
for j in range(len(l)):
k=l[j]*5
sum1=0
for h in range(1,k+1,2):
sum1=sum1+h
print(snm(sum1))
Example 2: convert python to java
s=input()
l=[]
s1='aeiou'
sum1=0
def snm(sum1):
t=0
while(sum1>0 or t>9):
if(sum1==0):
sum1=t
t=0
t=t+sum1%10
sum1=sum1//10
return t
Example 3: convert python to java
import check50
import check50_java
@check50.check()
def book_exists():
"""Book.java exists."""
check50.exists("Book.java")
@check50.check(book_exists)
def book_compiles():
"""Book.java compiles."""
check50_java.compile("Book.java")
@check50.check()
def press_exists():
"""Press.java exists."""
check50.exists("Press.java")
@check50.check(press_exists)
def press_compiles():
"""Press.java compiles."""
check50_java.compile("Press.java")
@check50.check()
def vm_exists():
"""VendingMachine.java exists."""
check50.exists("VendingMachine.java")
@check50.check(vm_exists)
def vm_compiles():
"""VendingMachine.java compiles."""
check50_java.compile("VendingMachine.java")
Example 4: convert python to java
import check50
import check50_java
@check50.check()
def book_exists():
"""Book.java exists."""
check50.exists("Book.java")
@check50.check(book_exists)
def book_compiles():
"""Book.java compiles."""
check50_java.compile("Book.java")
@check50.check()
def press_exists():
"""Press.java exists."""
check50.exists("Press.java")
@check50.check(press_exists)
def press_compiles():
"""Press.java compiles."""
check50_java.compile("Press.java")
@check50.check()
def vm_exists():
"""VendingMachine.java exists."""
check50.exists("VendingMachine.java")
@check50.check(vm_exists)
def vm_compiles():
"""VendingMachine.java compiles."""
check50_java.compile("VendingMachine.java")
Example 5: convert python to java
import check50
import check50_java
@check50.check()
def book_exists():
"""Book.java exists."""
check50.exists("Book.java")
@check50.check(book_exists)
def book_compiles():
"""Book.java compiles."""
check50_java.compile("Book.java")
@check50.check()
def press_exists():
"""Press.java exists."""
check50.exists("Press.java")
@check50.check(press_exists)
def press_compiles():
"""Press.java compiles."""
check50_java.compile("Press.java")
@check50.check()
def vm_exists():
"""VendingMachine.java exists."""
check50.exists("VendingMachine.java")
@check50.check(vm_exists)
def vm_compiles():
"""VendingMachine.java compiles."""
check50_java.compile("VendingMachine.java")
Example 6: convert python to java
import check50
import check50_java
@check50.check()
def book_exists():
"""Book.java exists."""
check50.exists("Book.java")
@check50.check(book_exists)
def book_compiles():
"""Book.java compiles."""
check50_java.compile("Book.java")
@check50.check()
def press_exists():
"""Press.java exists."""
check50.exists("Press.java")
@check50.check(press_exists)
def press_compiles():
"""Press.java compiles."""
check50_java.compile("Press.java")
@check50.check()
def vm_exists():
"""VendingMachine.java exists."""
check50.exists("VendingMachine.java")
@check50.check(vm_exists)
def vm_compiles():
"""VendingMachine.java compiles."""
check50_java.compile("VendingMachine.java")