CSci 1133 Lab Exercise 13


Category: You will Instantly receive a download link for .zip solution file upon Payment


5/5 - (5 votes)

Java is a powerful programming language and is arguably the most popular and widely used computer
language today. If you’ve seen the news lately about driverless cars, the first prototypes were actually
coded in Java!
In this lab, you will practice working with a few simple Java programs. As you’ve learned in lecture, there
are several important differences between Python and Java. These range from type restrictions (Java is
“statically typed” while Python is “dynamically typed”), to things as simple as having to add a semicolon
after each line.
Warm up
Let’s get started. One of the easiest ways to learn the nuances of a new programming language is to
convert a simple program from a language that you already know into the language you are trying to
learn. Take comfort in the knowledge that the semantic principles are identical, regardless the language!
Consider the following Python program that determines all the perfect numbers between 1 and some
upper-bound provided by the user. Recall that a perfect number is one in which the sum of all of its
divisors (except for the number itself) equals itself ( e.g. 6 = 1 + 2 + 3 ). Convert this Python program to
its Java equivalent. Name the Java main class PerfectNum.
def main():
limit = int(input(“Enter the upper limit: “))
while n <= limit: i=1 factorsum = 0 while i